German Unification was a process that took almost all of the 19th century. Before Unification Germany was just a bunch of miscellaneous shapes.
This push to Unifying Germany would prove difficult, since Germany was all separate parts, each part had developed their own religious,. social, and cultural differences.
The Holy Roman Empire alone had 500 independent states when it dissolved in 1806. The German speaking people of the old empire all shared linguistic, cultural, and legal traditions.
These traditions were further enhanced by the French Revolutionary war, and the Napoleonic wars.
The number of fragmented German states dropped considerably from several hundred to several dozen in the aftermath of the 1815 congress of Vienna after the Napoleonic wars.
This is because the Austrians dominated central Europe with a loosely organized German confederation.
After the wars there were the revolutions of 1848, during this time German Unification was a major objective. Therefore German states met and created a federal union with a national parliament to be elected. This led to parliament electing Otto Von Bismarck as emperor.
Bismarck, made it his goal to unify the German states. Thus after he manipulated a letter sent by the French Ambassador to the German states, The states then rallied to the side of Prussia thus unifying them as a whole. They then went on to defeat the French in battle.