The Reformation happened inside the empire and could not have happened in the same way anywhere else. When Luther refused to recant at the Diet of Worms in 1521 he was condemned by the emperor and protected by his own prince, and the empire's division of authority meant that no single ruler could enforce a single religion across it. Four decades of manoeuvre and war produced the Peace of Augsburg in 1555, which recognised Lutheran and Catholic territories and left the choice to each ruler, a principle later summarised as whose realm, his religion, with a right of emigration for subjects who dissented.
Augsburg left out the Calvinists, said nothing durable about church lands already secularised, and settled nothing about the ambitions of either confession, and the arrangement broke down into the Thirty Years War of 1618 to 1648. The Peace of Westphalia rebuilt it on firmer ground: Calvinism admitted, 1624 fixed as the year by which territorial confession and church property would be judged, private worship and emigration guaranteed to dissenting subjects, and the imperial courts staffed in confessional parity.
That settlement held for a century and a half and left the confessional map of Germany much as it stands today. The empire itself was dissolved in 1806 under Napoleon, and its ecclesiastical principalities had already been secularised wholesale in 1803, ending the long European experiment of bishops who were also princes.