We use SVN at work, but for my personal projects I decided to use Git. So I installed Git yesterday, and I wonder what is the revision number equivalent in Git.
Let's say we work on version 3.0.8 and every bug fix has its own revision number we can use when we talk about this bug fix. So if I tag the code in Git to 3.0.8 what then I can use as a revision number or some other more detailed kind of identification? I find the hash not so user friendly for humans.
With modern Git (1.8.3.4 in my case) and not using branches you can do:
Along with the SHA-1 id of the commit, date and time of the server time would have helped?
Something like this:
This is what I did in my makefile based on others solutions. Note not only does this give your code a revision number, it also appends the hash which allows you to recreate the release.
Each commit has a unique hash. Other than that there are no revision numbers in git. You'll have to tag commits yourself if you want more user-friendliness.
The other posters are right, there is no "revision-number".
I think the best way is to use Tags for "releases"!
But I made use of the following to fake revision numbers (just for clients to see revisions and the progress, as they wanted to have the same increasing revisions from git as they where use to by subversion).
Show the "current revision" of "HEAD" is simulated by using this:
git rev-list HEAD | wc -l
But what if the client tells me that there is a bug in "revision" 1302 ?
For this I added the following to the [alias] section of my ~/.gitconfig:
show-rev-number = !sh -c 'git rev-list --reverse HEAD | nl | awk \"{ if(\\$1 == "$0") { print \\$2 }}\"'
using
git show-rev-number 1302
will then print the hash for the "revision" :)I made a Blog Post (in german) about that "technique" some time ago.
A Bash function:
outputs something like
That is