tags:

views:

269

answers:

2

How do I enable ident $Id$ on files in a Git repository?

+2  A: 

You can do this by adding a pattern for which files you want this functionality followed by ident in the .gitattributes file. This will replace $Id$ with $Id:<40-digit SHA>$ on checkout of the file. Notice though that it won't give you a revision number of the file as in CVS/SVN.

Example:

$ echo '*.txt ident' >> .gitattributes
$ echo '$Id$' > test.txt
$ git commit -a -m "test"

$ rm test.txt
$ git checkout -- test.txt
$ cat test.txt

Link to gitattributes(5) Manual Page

m5h
I just played around with this and as far as I can tell this gives only a SHA for a specific file, not an $Id$ for the entire repository.
Aaron
+3  A: 
Jakub Narębski