Some surnames are based on the names of the places where they live, such as Dongmen, Ximen, Dongguo, Nanguo, etc. (A wall built around the city in ancient times was called "Guo").
Some use the official title as their surname. For example, "Si" means to preside over. Sikong is responsible for the construction of water conservancy and civil engineering projects in the world; Sikou is in charge of public security; Sima is the military chief; Situ is in charge of educating the people and administrative affairs, and his position is equivalent to the prime minister.
Some people use the name of their country as their surname. There was a country named Zhongli in the Zhou Dynasty, which was annexed by the Kingdom of Chu in the Spring and Autumn Period, so its people used "Zhongli" as their surname. In the Spring and Autumn Period, there was a country called Chunyu, but it was later destroyed by other countries, and their descendants used "Chunyu" as their surname.
Some people combine country names and place names to make surnames. King Zhou of Shang had an uncle named Jizi. He often advised King Zhou of Shang not to be greedy for enjoyment, but to focus on governing the country. King Zhou not only refused to listen, but imprisoned him. After King Wu of Zhou destroyed the Shang Dynasty, he released Ji Zi and made him an official. But Jizi did not want to be a minister of Zhou Dynasty, so he came to Liaodong and established the state of Korea. His descendants had a fiefdom in the place "Yu", so they took one character from the name of the country and the name of the place and combined it into "Xianyu" as the surname.
Some use tribal names as surnames, such as "Wanqi, Murong, Yuchi, Yuwen" and so on. They were all tribal names of the Xianbei people in ancient times, and the tribesmen later used these tribal names as surnames.
Some use a certain title as their surname, such as "Gongsun". In ancient times, according to the hereditary system of the Zhou Dynasty, the king was succeeded by the eldest son, who was called the prince before succeeding to the throne. The other sons were called the prince, and the son of the prince was called the grandson. Some of their descendants took "Gongsun" as their surname.
Some people use nicknames as surnames. During the Spring and Autumn Period, Shaozhengmao, a senior official in the State of Lu, was very knowledgeable and eloquent. He was very famous in society and was called a "Wenren" by everyone. His descendants used "Wenren" as their surname.
Some people use the seniority in the family as their surname, such as "eldest grandson". There are also ancestral characters used as surnames, such as "Huangfu" and so on.
The surname "Zhuge" has two origins. One is that after the demise of Ge Bo's feudal kingdom, some Chinese people moved to various cities in Shandong, so they were called "Zhuge". The other is that at the end of the Qin Dynasty, Chen Sheng rebelled. General Ge Ying made many military exploits, but was killed by Chen Sheng because of his slander. Later, Emperor Wen of the Western Han Dynasty made Ge Ying's grandson a prince of various counties, and their descendants used "Zhuge" as their surname.