Long time ago when Lord Shiva, was away fighting for the gods, the lady of the house, Goddess Parvati was alone at home. On one occasion, she needed someone to guard the house when she was going for a bath. Unable to think of an alternative, she used her powers to create a son, Ganesh. She instructed Ganesh to keep strict vigil on the entrance to the house and not to allow anyone into the house. Ganesh agreed and stayed on the strictest of strict vigils.
In the meantime Lord Shiva returned happy after a glorious victory for the gods, only to be stopped at the entrance by Ganesh. Ganesh, acting on Parvati’s orders verbatim, did not allow Shiva to enter the house. Lord Shiva was enraged beyond control and in a fit of rage slashed the head of Ganesh. In the meantime Parvati came out from her bath and was aghast at the scene. She was very angry at her lordship for what had happened and explained him the situation.
Lord Shiva wanted to make it up to Parvati very badly and agreed to put life back into Ganesha by putting the head of the first sleeping living creature that came in sight which was sleeping with its head to the north. He sent his soldiers to go in search of the creature. The first creature which came in sight was an elephant. So Lord Shiva re-created his son with the head of the elephant. Hence the trunk of Lord Ganesha.
Parvati was still not totally happy with the deal and wanted more. Then Shiva granted Ganesha a boon that before beginning of any undertaking or task people would worship Lord Ganesh. Lord Ganesh has to power to remove any obstacles that come in the way of all true devotees. So before starting any new project or work it is good to pray to Lord Ganesh with all shradha and bhakti for the successful completion of the task undertaken.