I would like to create Git hook(s) that will populate the commit id of the commit I am about to make into a file (basically variable substitution) in my source code. Is this
You can create a filter which does substitution on files on commit and checkout. These are called "smudge" and "clean" filters and their operation is controlled through .gitattributes. For example:
*.c filter=yourfilter
This tells git to run the yourfilter filter for all .c files. You then have to tell git what yourfilter means:
git config --global filter.yourfilter.clean script1
git config --global filter.yourfilter.smudge script2
You'd then write a script (sed, Perl, Python, or anything) to replace an expression like $LastSha$ with $LastSha: on checkout ("smudge"). The other script reverses the expansion before commit ("clean".)
Search the Pro Git book for "Keyword Expansion" for a detailed example.