The Germans did this through unrestricted submarine warfare. The rules of the time said that it was legitimate to sink unarmed merchant ships even if they were not carrying military materials (because everything is important in time of war). However, submarines were supposed to surface, warn the ship, and give its crew time to get off the ship into lifeboats. The Germans did not want to do this because it would have seriously reduced their ability to blockade England. In addition, they did not want to do it because the British had ships that had concealed weapons and could destroy a submarine that surfaced to warn it.
For this reason, the Germans did not obey rules that put them at a disadvantage in the war.