0

My example repository is this one with its last commit (K + 1) and I want to automatically insert the previous one's ( K ) commit ID ( The hash at the end of the URL) inside a source file in the repo when I commit (K + 1) ( Let's say test.c ). How can I make it, so this commit ID gets inserted in to the source like a string. So far I Google-ed and found the following strings:

$Id:$ $Id$ 

But so far nether of those can make it ( c2928d9091e0743cb22b38d962c75f97791767a0 ) appear inside test.c

That way I can make the particular system print this hash, to identify on which machine which version do I have.

5
  • Check this. Commented Aug 19, 2015 at 11:38
  • This one is for Linux, and I guess I should run those commands somehow "git rev-parse HEAD > filename" Commented Aug 19, 2015 at 11:54
  • possible duplicate of How can I populate the Git commit ID into a file when I commit? Commented Aug 19, 2015 at 12:44
  • How can I make those Git attributes. In the ".git" there is no such ting, but when I try to create a file with that name i get "You must specify a file name" because it has only extension.... Commented Aug 19, 2015 at 13:07
  • I tried with the last commit github.com/dvdvideo1234/Test Managed to add ".gitattributes" with "test.c ident" inside it and "Git Commit ID: $Id$" inside "test.c" Commented Aug 19, 2015 at 13:20

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.