How would I go about simulating a global increasing revision number for every commit in the git main line?
So, after I commit I would like a script to run increases a number somewhere.
This will allow me to tell my customers easily that X feature was fixed in git revision XYZ.
I am looking for a practical sample script that is robust enough to handle pushes and merges to a degree.
Other than that there are no revision numbers in git. You'll have to tag commits yourself if you want more user-friendliness.
Just use git rev-parse master (or git rev-parse refs/heads/master if you need to be completely unambiguous). git describe is what I was looking for.
So "revision" refers to the id you can use as a parameter to reference an object in git (usually a commit). HEAD@{5 minutes ago} is a revision which reference the commit present 5 minutes ago.
The exact git revision number begins with the prefix g6f10c (these 6 digits should be enough to uniquely identify the commit if you need to refer to that revision in particular). You can see released versions by running git tag and you can get version 1.7. 3.2 exactly by running git checkout v1. 7.3.
git describe
gives you a version description like the following: v2.0-64-g835c907
. The v2.0
part is the name of the latest annotated tag preceding the commit, 64
is the number of commits after that, and 835c907
is the abbreviated commit id. It is basically there to identify any revision in an exact and convenient (although technical) way.
Note: For this to work you will need at least one annotated tag. To create one for version v2.0 run - git tag -a v2.0
, if you have no annotated tags this command will fail, unless given a fallback argument like --tags
or --always
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With