My questions is was the term Italy and Italian people used in the medival kingdoms of Europe and among the city states and duchys of the italian peninsula or were there clear separations between Venice,Genoa,Ferrara,Napels, Papal State etc. Did they have a sense of common identity?
After the fall of the Roman empire, Italy continued to a more or less unified and autonomous polity until the 8th century, and would not become definitively fragmented until the 10th.
After the fall of the Second Kingdom of Italy, the word "Lombard" (after the ethnicity of the old ruling class) denoted anything indigenously Italian in both north and south ("Frankish" was anything associated with the new ruling class). The earliest examples of what can be called written Italian appear in Benevento in the ninth century, while the nearby "Lombard" city of Salerno would become a major Mediterranean entrepôt and come to house a renowned University.
In northern Italy, after the wars of succession following Charlemagne's death, the Kingdom of Italy was given to Lothair (a grandson of Charlemagne) in 795. The unstable transitions between emperors in the Carolingian dynasty would ended in 887, after the deposition of Charles the Fat. Charles was the last Emperor to simultaneously hold the title of King of Italy, France, and Germany, and had even been elevated to the Imperial Throne from the position of King of Italy. However, he possessed no direct heirs, and the fight between innumerable female-line descendants was on.
The Marquis of Ivrea managed to get crowned King Berengar II in the late ninth century, however it wouldn't be long before the German Kaiser Otto decided to take the crown for himself.
The Ottonian Emperors Otto I, Otto II, Otto III, and Henry II would all travel to Italy to be crowned King of Italy by an Italian Bishop. Absurdly, the Ottonians came to rely on Italian revenues to contrast the unruly vassals in Flanders, Bavaria and Luxembourg. With the Italian lords having fought themselves into irrelevance in wars of succession of the early tenth century, Italy came to be one of the most centralized parts of the Empire. This arrangement would last until Henry II died without issue in 1024. And here it gets interesting, because although Conrad the Salian is elected emperor with minimum fuss in Germany, in Italy his ascension is not entirely recognized.
The Ottonians understood Italy, especially thanks to Otto II's marriage to the Byzantine princess Theophanu, but the same could not be said about the Salians. Almost as soon as Conrad II was elevated to the throne, his legitimacy in Italy was contested. Conrad condemned the "Lombards" in court, but no punitive action was taken: the lack of a strong landed aristocracy meant that Conrad had no military means to counter Italian cities doing as they pleased without transporting knights over the Alps. After Conrad convened a synod in Pavia to hear out the complaints, he got so infuriated by the dissidence of the Italian leaders he ordered the arrest of the bishop of Milan Aribert of Intimiano. However, imperial influence in Italy had almost completely eroded: Aribert fled back to Milan unhindered. Conrad tried to forcefully enter the city to seize him, but couldn't round up enough support. It would seem, then, that the Kingdom of Italy was ungovernable.
In between the eleventh and fourteenth centuries, when the Italian cities established themselves as self-governing but didn't yet evolve into states with jurisdictions beyond their city walls; so although Italy certainly continued to exist as a geographic and political construct, identity was most definitely tied to one's city or region. One of my favorite quotes from the Divine Comedy reads as follows:
Non omo, omo già fui, e li parenti miei furon lombardi, Mantoani per patria ambedui
This is Virgil introducing himself to Dante. Virgil says, "Man I am not but man I once was, my parents were Lombards, Mantuans by homeland both."
Dante commits an anachronism; Lombards wouldn't arrive in Mantua for hundreds of years at the time of Virgil's birth. But what's interesting here the way Dante calls "Lombards" the inhabitants of Northern Italy as late as the fourteenth century.
But specifying "Lombard" isn't enough, Dante finds it necessary to affirm that Virgil's parents are both "Mantuans." So here we have a demonstration as to how identity on the peninsula is mostly tied to the urban communities.
It's important to reaffirm that the concept Italy never disappeared: In the second decade of the fourteenth century, for example, Boccacio would write that Canagrande Della Scala (Lord of Verona) was "One of the most notable and magnificent lords known in Italy since the Emperor Frederick" while the poet Niccolò de' Rossi affirmed that Canagrande "Will be king of Italy by next year" (Canagrande dropped dead at forty and did no such thing, but that's not the point).
Fast forward to the Battle of Fornovo in 1495, when the Italian states chased the already retreating Charles the VIII of France from Italy. Duke Lodovico Sforza of Milan and Pope Alexander had asked Charles to conquer the Kingdom of Naples, but then freaked out when he actually did conquer the Kingdom of Naples. They then set up a league to stop him (long story). After the battle, Milan made a hasty separate peace at Vercelli; and "Treachery!" cried the other members of the League, who then snubbed Milan (who had born the brunt of the fighting) and proclaimed the Republic of Venice "Liberator of Italy" after Charles was forced to hand the Kingdom of Naples back over to King Alfonso after his Alfonso's son Ferrante landed in Calabria at the head of an army courtesy of his Spanish cousins.
Fast forward again to the negotiations ar the Peace of Utreicht after the War of Spanish succession in 1713, and the Venetian Ambassador Carlo Ruzzini reported that the Republic of Venice was seen as "La Principale Potenza e Protettrice d'Italia" or "Principal Power and Protector of Italy."
So clearly, the notion of "Italy" doesn't seem to have mutated in the two hundred years since the solidification of the half dozen independent polities on the peninsula, although the concept of Italian identity would only be formed after Napoleon's conquest of the peninsula. However, even during the Risorgimento (the Italian Unification process) Camillo Benso of Cavour, the Prime Minister of Piedmont (the Italian state which conquered the peninsula) would have been perfectly content with stopping at the conquest of Rome. It's a strange set of circumstances which led Garibaldi and his Redshirts, who were fundamentally paramilitaries, to organize their expedition conquering the south of the Peninsula. However, conquer they did, and "Italy" now refers to the entire peninsula and the state that governs it.