Tuesday 6 August 2019

Moving from SVN to git: $Id:$ equivalent


In SVN (and CVS), you could include special strings such as
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):
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:
You should now see the $Id: followed by a commit hash string:
reference: http://stackoverflow.com/questions/384108/moving-from-cvs-to-git-id-equivalent

I have no experience with SVN , butI believe the git way of doing this would be with tags.
After a specific commit, you can do:
git tag -a -m “”
Afterwards, you can simply do:
git checkout
That will check you out to the specific commit where the tag was created.
To push tags:
git push –tags
To pull, simply:
git fetch

0 comments:

Post a Comment