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.

  • Check [this](http://stackoverflow.com/questions/3442874/in-git-how-can-i-write-the-current-commit-hash-to-a-file-in-the-same-commit). – Deepak Biswal Aug 19 '15 at 11:38
  • This one is for Linux, and I guess I should run those commands somehow "git rev-parse HEAD > filename" – Деян Добромиров Aug 19 '15 at 11:54
  • possible duplicate of [How can I populate the Git commit ID into a file when I commit?](http://stackoverflow.com/questions/16524225/how-can-i-populate-the-git-commit-id-into-a-file-when-i-commit) – joran Aug 19 '15 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.... – Деян Добромиров Aug 19 '15 at 13:07
  • I tried with the last commit https://github.com/dvdvideo1234/Test Managed to add ".gitattributes" with "test.c ident" inside it and "Git Commit ID: $Id$" inside "test.c" – Деян Добромиров Aug 19 '15 at 13:20

0 Answers0