Katja Hoyer, an Anglo-German historian and journalist, is the author of “Blood and Iron: The Rise and Fall of the German Empire 1871-1918.”

Just as prevention is better than cure, deterrence is better than war. As Russian President Vladimir Putin amasses troops along Russia’s border with Ukraine, the West will have to convince him that the risks of an attack outweigh its potential gains. This cannot be a task for the United States alone. European NATO partners, most notably Germany, will have to step up to the plate.

As The Post reported last week, U.S. intelligence believes Russia is planning a complex military operation against Ukraine involving up to 175,000 troops. In light of this mounting threat, President Biden met with Putin in a virtual summit on Tuesday. Biden confirmed he is planning “the most comprehensive and meaningful set of initiatives to make it very, very difficult for Mr. Putin to go ahead.”

But defending Europe’s eastern borders cannot be solely a U.S. effort. Germany, the United States’ largest ally in Europe, stood by as Putin invaded Georgia (2008) and annexed Crimea (2014). Perhaps out of a misguided sense of continued guilt over Germany’s history of militarism, then-Chancellor Angela Merkel hesitated, opting to pander to the pacifist tendencies in her country — so much so that Putin no longer believes that he will face any retaliation for his actions. Deterrence will have an effect only if Russia can be convinced that NATO stands united against an attack on Ukraine.

Josep Borrell, the European Union’s foreign policy chief, made the right noises when he pledged “unwavering support” for Ukraine on Twitter. But as a European army is currently a pipe dream, all that Brussels has to offer by way of deterrence are economic sanctions. Putin knows that such sanctions would be as painful to Europe as they would be to Russia. In fact, they are nearly impossible — thanks to the energy crisis that Europeans are currently experiencing.

As things stand now, Russia supplies a quarter of the E.U.’s oil and 40 percent of its gas. Germany’s controversial Nord Stream 2 pipeline, which runs under the Baltic Sea — bypassing Ukraine, unlike some of earlier routes — will make this dependency worse. Putin has already tested the political potential of this situation by withholding gas supplies when Europe recently asked for more.

Deterrence works only if the other side believes that you mean business. Putin knows that the E.U. will not risk high energy prices, power outages and domestic friction to protect the integrity of Ukraine. The invasions of Georgia and Crimea showed this. And now that Germany is phasing out nuclear energy and coal, European dependency on Russian gas is more severe than ever.

With so little credibility behind economic threats, the only way to make deterrence work is a united military front through NATO. Merkel’s 16-year tenure has done much damage in this regard. A Russian speaker who grew up in East Germany, she has always had a very personal relationship with Putin, who speaks fluent German and also spent years in East Germany as a KGB agent. In conflicts, Merkel’s first instinct was to call Moscow directly, going over the heads of the people of Eastern Europe. She has done the same during the recent migrant crisis in Belarus, making two calls to Belarusian dictator Alexander Lukashenko.

The new German government will have to break this pattern of bilateral diplomacy, which is sowing resentment among its European neighbors. There is growing suspicion that Berlin believes it has a special relationship with Moscow.

Germany’s designated new foreign minister, Annalena Baerbock of the Green Party, sounds reassuringly hawkish. She has said that Nord Stream 2 should be suspended. “We must not allow ourselves to be blackmailed,” she declared. Her co-leader of the Greens, Robert Habeck, who will be the country’s next economy minister, has stated that Germany should supply Ukraine with weapons and equipment.

The Greens, however, are only a junior partner in Germany’s new coalition government, which will be led by the Social Democrat Olaf Scholz, Merkel’s replacement as chancellor. His party has a long track record of pro-Russian policies. It was the last Social Democratic chancellor, Gerhard Schroeder, a close friend of Putin’s, who initiated Nord Stream 2. He remains the chairman of the project’s Shareholders’ Committee.

The new government’s political road map for Germany for the next four years highlights the inherent contradictions of the government’s stance. It says that Germany’s “transatlantic alliance is a central pillar and NATO an indispensable part of our security.” But it also argues that “we need an offensive for disarmament” and a “Germany free of nuclear weapons.” Similarly, it claims that Germany will take “the concerns especially of our Eastern European partner states seriously” but then speaks of “differences in the perception of threat” between them and Russia that need to be “acknowledged.”

Here is the reality: Putin has already stationed 70,000 soldiers on the Ukrainian border, and Russian Foreign Minister Sergei Lavrov is threatening a return to “the nightmare scenario of a military confrontation.” Given these ominous circumstances, the new government in Berlin needs to show that there is real resolve behind its words. Deterrence needs to work. Far more than the loss of international prestige is at stake.