At the time of Ganesha’s ‘birth’, Shiva was away from the family home. On returning, and finding an unknown young man standing guard outside the bathroom of his wife, he naturally challenged him. Ganesha was equally unknowing of his father, and the two came to blows. The result was never in doubt, for Shiva is the greatest of the Gods, and the father killed his own son, by cutting off his (human) head.
The story continues here: https://medium.com/@Kattenkopjes/ganesha-f7d92818f83f