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
OK, inspired by Jon Cairns' answer, I came up with this little snippet you could put in your Makefile.
version.h: git log -n 1 --format=format:"#define GIT_COMMIT \"%h\"%n" HEAD > $@
It's not a completely general solution, but it could come in handy. I know a place or two where I'll be using it.