So I’ve been reading about the unification of these two countries, nationalism and all that jazz. I’m wondering though, did people from these places call themselves that before unification. So pre 1860s and 70s did someone from The kingdom of Bavaria call themselves German or Bavarian? Similarly did someone from the kingdom of two Sicilies call themselves Italian or sicilian? Did foreigners refer to them as such?
The short answer at the idea of a nation as well as nationalism in various forms both in Italy and in Germany goes a lot farther back than you might think. In fact, we can trace it back to the Middle Ages.
But it's all a bit complicated, so allow me to elaborate a little. The following is intended to provide a few highlights of a century-long development; there would be much more to say. Also, please keep in mind that my expertise is mainly in the early modern period (1500-1800), for the
19th century perhaps someone else can add more.
A milestone in the formation of national identities in both Germany and Italy was humanism, which emerged in Italy as early as the 14th century and was more widely adopted in Germany in the 15th century.
However, examples of early forms of nationalism can already be found in the centuries before. In the early 13th century, Walther von der Vogelweide, one of the most famous German "Minnesänger" (troubadours) wrote a lot of political poems, among other things. In his "Unmutston" he accused the pope of conspirering with his Italians ("sînen Walhen") to extract riches from German lands. He lets the pope say: "German silver goes into my Italian coffers" ("tiuschez silber vert in mînen welschen schrîn“). The contrast with Italy, but also with France, remained an important element in the construction of German nationalism later on.
In Italy, the idea of nationhood in humanist circles was deeply linked to the idea of one's own superiority over other nations. Just as the Romans had been superior to the barbaric northern Europeans, the educated classes in the Italian cities saw themselves as superior to the German and French barbarians. This idea was reinforced by reading ancient authors, especially Tacitus. In his „Germania“, Tacitus described the Germanic tribes as primitive barbarians who, on the other hand, were morally superior to the Romans, in certain ways at least. This text was taken up by both Italian and German humanists to justify their own superiority over the other nation.
We must now keep in mind that this humanist nationalism was something that was supported by a small educated elite. At least initially, it wasn‘t widely adopted by the ordinary people. For the politically powerfull, their membership in the nobility remained more important than belonging to whichever nation. However, some of them at least used it to legitimize some of their actions. Holy Roman Emperor Frederick III (1440-1493) and his son Maximilian I (1493-1519) frequently claimed that their policy served to defend the honour of the German nation. Meanwhile, Pope Julius II 1503-1513) made the battle cry "Fuori i barbari" („Out with the barbarians!“ – from Italy) the motto of his wars against France.
A few years later, Martin Luther took up the humanist nation idea. For him, the Reformation was, among other things, the liberation of the German Church from the papacy - an Italian institution. Luther's books and pamphlets were extremely successful and were read (or listened to) by many. This also spread the idea of nationhood. Furthermore, by translating the Bible, Luther made a decisive contribution to the formation of a unified German literary language. In Italy, a norm based on the Tuscan dialect in which Dante and Boccaccio had written had been established for some time at this point.
However, all these thoughts of national identity did not yet lead to demands for political unification. These only began in the 18th century, with the Enlightenment, and frequently coincided with a republican, anti-monarchic sentiment. In Friedrich Schiller‘s famous play „Die Räuber“ (The Robbers, first published in 1781) for example, the protagonist Karl Moor exclaims: „Germany shall become a republic.“ (aus Deutschland soll eine Republik werden).
The real breakthrough of nationalism in Germany then came with the Napoleonic wars, which were legitimised as national defensive struggles against France in Prussia and Austria, but also in the smaller states of the now dissolved Holy Roman Empire. Contrary to the interests of the German monarchies, however, the republican idea also remained influential and vented itself in the revolution of 1848/49. In Italy, too, the revolution of 1848 was both national and at least partly republican in character.
Still, both the German and the Italian nation states were created "from above", by Prussia and Sardinia-Piedmont respectively, not by the people themselves. Moreover, in both countries, there are strong regional identities alongside the national ones to this day. This is also reflected in more or less strong separatist movements in individual regions, for example Bavaria and Veneto.
To this day, Germany has a strongly federalist constitution that grants many rights to the individual federal states. Although Italy has a centralised structure, for a long time (in part until today) it had regional identities in large sections of the population that were far stronger than the national one.
And that leads me to a summary answer to your question: depending on the era, but also on the social class, people sometimes felt they belonged more to the region, sometimes more to the nation. Moreover, the two are not mutually exclusive. A peasant in 16th century Tuscany probably felt much more Tuscan than Italian. A lawyer in early 19th century Milan might have considered himself Italian first, Lombard second. The general idea of an Italian nation and of a German nation developed quite early, long before the unification of the respective nation states. People have been identified as Germans or Italians both by their countrymen as well as by foreigners for a long time, but at the same time they continued and still continue to also identify as Bavarians and Saxons, Sicilians and Venetians. In places like Bavaria or Naples you can also still find quite a few people who will be offended when you call them Germans oder Italians.