Moving from SVN to git: $Id:$ equivalent

In SVN (and CVS), you could include special strings such as

$Id:$

and after a commit, the revision number would appear after “Id:”, which was a convenient way to retrieve the revision for instance in a print statement.

Apparently, with GIT, the equivalent does not exist by default. Indeed somebody could refer to version 1.1 of a file but your
version 1.1 of that file is different and so it would not make sense to keep track of a revision.

Yet, there is way to include the hash from GIT. First, go the repository you are working one and add (if you want to add $Id:$ in a Python code):

cat .git/info/attributes 
# see man gitattributes
*.py ident

Then put $Id$ somewhere in the file (on top generally)

Then commit. Note you will need to delete the file and check it out again:

git commit foo.sh
rm foo.sh
git co foo.sh

You should now see the $Id: followed by a commit hash string:

# $Id: 143e77a7f07343b14 $

reference: http://stackoverflow.com/questions/384108/moving-from-cvs-to-git-id-equivalent

Please follow and like us:
This entry was posted in Software development, Uncategorized and tagged . Bookmark the permalink.

One Response to Moving from SVN to git: $Id:$ equivalent

Leave a Reply

Your email address will not be published. Required fields are marked *