What are some good books on how common people identified throughout history in the sense of them belonging to a collective, from tribal to ethnic and national collective, and generally how those concepts emerged and evolved through time?
The classic text that comes to mind is The Invention of Tradition (1983), edited by Eric Hobsbawm and Terence Ranger. It is a collection of essays that explore how nationalism developed in various (primarily British) contexts. It argues that collective identity is not something natural, but rather is manufactured. It may, though, fall short of what you seek if you are looking for the history of how people, globally, have felt about collective identity over time. It focuses on case studies of how certain identities began, as a way to demonstrate their artifice.
Google Books summary:
Many of the traditions which we think of as very ancient in their origins were not in fact sanctioned by long usage over the centuries, but were invented comparatively recently. This book explores examples of this process of invention - the creation of Welsh and Scottish 'national culture'; the elaboration of British royal rituals in the nineteenth and twentieth centuries; the origins of imperial rituals in British India and Africa; and the attempts by radical movements to develop counter-traditions of their own. It addresses the complex interaction of past and present, bringing together historians and anthropologists in a fascinating study of ritual and symbolism which poses new questions for the understanding of our history.
The other classic text, though I have not read it, is Benedict Anderson's field spurring Imagined Communities, written a year before:
Anderson examines the creation and global spread of the ‘imagined communities’ of nationality, and explores the processes that created these communities: the territorialization of religious faiths, the decline of antique kinship, the interaction between capitalism and print, the development of secular languages-of-state, and changing conceptions of time and space. He shows how an originary nationalism born in the Americas was adopted by popular movements in Europe, by imperialist powers, and by the movements of anti-imperialist resistance in Asia and Africa.