Built-in git commit hash in source file

Possible duplicate:
In Git, how can I write the current commit hash to a file in the same commit

We are stuck in an extremely unfortunate but inevitable problem when you have to periodically deploy our code development builds directly from the oven. After some time, we lose track of whose installation is based on what kind of "intermediate" unlabeled version of the code base.

Does git provide an automatic macro or token embedded in tracked files that are automatically replaced with the latest commit hash identifier from HEAD when using git clone 'or whatnot?

Of course, there must be a way to do this; even RCS, a completely Jurassic system by the standards of today's cool kids, had a built-in version variable that it could replace.

+3
source share
1 answer

As you can read the answers to the Ben James question posted in commnets, people are having trouble placing commit hash values ​​in files using git.

Is it possible to use a scripted solution outside of git? When you need to deploy a new assembly from git, you can create a tag, check it before you build your tar.gz release, or whatever you add the tag name to each source file. Guess that you can automate this, perhaps with git-archive or something else.

, , - , , , git - SHA1. , , SHA1. cat-file

+1

Source: https://habr.com/ru/post/1773002/


All Articles