I’m trying to do a fancy stuff here with Git hooks, but I don’t really know how to do it (or if it’s possible).
What I need to do is: in every commit I want to take its hash and then update a file in the commit with this hash.
Any ideas?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I would recommend doing something similar to what you have in mind: placing the SHA1 in an untracked file, generated as part of the build/installation/deployment process. It’s obviously easy to do (
git rev-parse HEAD > filenameor perhapsgit describe [--tags] > filename), and it avoids doing anything crazy like ending up with a file that’s different from what git’s tracking.Your code can then reference this file when it needs the version number, or a build process could incorporate the information into the final product. The latter is actually how git itself gets its version numbers – the build process grabs the version number out of the repo, then builds it into the executable.