Confucius didn’t “do god” in the sense of worshiping a specific deity or religion, but he did subscribe to a belief in the idea of an all-seeing and all-knowing “heaven” (天/tiān) that acted as a sort of moral guide for the world and bestowed its will or mandate (命/mìng) on virtuous individuals to rule the world wisely and benignly.
These included the ancient sage kings Yao and Shun, as well as the founders of the Xia, Shang, and Zhou dynasties, all of whom Confucius believed were given the mandate of heaven to bring peace and prosperity to society. Confucius also included his own personal hero the Duke of Zhou on the list of recipients, as well as his own good self.
When he says that at the age of fifty “I knew the mandate of heaven” in 2.4, Confucius is indicating that he understood and embraced the mission that heaven had given to him: namely to return his conflict-riven land to its former glory by restoring the traditional moral values exemplified by the Duke of Zhou when laying the foundations for the growth of the Zhou Dynasty.
The irony is, of course, that Confucius singularly failed in the mission that he believed heaven had given him – at least in his own lifetime. Perhaps the proliferation of his teachings among subsequent generations shows that he was right about it after all and that Heaven was just operating on a different time scale.
As the old saying goes, heaven works in mysterious ways.
(1) Confucius expresses his belief that he has been chosen by heaven a number of times in the Analects. In 9.6, for example, he declares when trapped in the rough border town of Kuang: “King Wen is dead, but the civilization he created lives on with me, doesn’t it? If heaven wished civilization to be destroyed, why was it entrusted to me?” Similarly, in 7.22 he claims “Heaven has bestowed me with virtue.”