Is there a way to include git commit hashes inside a file everytime I commit? I can only find out how to do this during archiving but I haven't been able to find out how to do this for every commit.
I'm doing scientific programming with git as revision control, so this kind of functionality would be very helpful for reproducibility reasons (i.e., have the git hash automatically included in all result files and figures).
You can easily put SHA-1 of file (to be more exact SHA-1 of blob, i.e. SHA-1 of contents of the file) by using
$Id$ keywork and
If you want to put SHA-1 of commit, there is no out-of-the-box solution, but you can use
smudge commands of
filter gitattribute. Note that would badly affect performance, as after commit each file would have to be modified to reflect new commit made.
Although as said in other answers to this question, you would do better on embedding version number in generated files when building, like e.g. Linux kernel and git project itself do it.