Before the campaigns of Napoleon, Germany was divided into hundreds of independent states and cities. Although the people were Germanic, they had little sense of national identity.
In the last decade of the 18th century, war broke out between France and the rest of Europe.
French Emperor Napoleon’s forces were strong enough to conquer and control the whole of mainland Europe, including the numerous German states.
Napoleon reorganised Germany into 39 larger states. He also established the Confederation of the Rhine, a league of 16 German states. This brought further unification to Germany.
Napoleon was defeated firstly at Leipzig in 1813 and then at Waterloo in 1815, bringing an end to the Confederation of Rhine.
Following Napoleon’s subjugation of Europe and the formation of the Confederation of the Rhine, the German states realised that being small and politically divided meant being vulnerable to strong aggressors. The states realised they needed each other for common defence.
The German princes stirred up nationalistic feelings in the German population to help raise armies to drive Napoleon's forces out of German territory. This was aided by the development of nationalist societies within the German universities.
Allied victory at the Battle of Leipzig in 1813 was partially a result of successful political and military cooperation between the German states.
The lessons learned by the defeat of Napoleon and the strong nationalism that was stirred up to finally drive him out, helped strengthen the sense of a common German identity.