How can I populate the Git commit ID into a file when I commit?

前端 未结 9 1509
生来不讨喜
生来不讨喜 2020-12-02 12:45

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

9条回答
  •  醉话见心
    2020-12-02 13:02

    It's impossible to do what you want: the commit's SHA-1 hash is calculated over the whole repository snapshot including each member file, so there's the chicken and egg problem — to calculate the commit's hash you need to know the contents of all the files which comprise it.

提交回复
热议问题