Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simulating a global revision number with git

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.

like image 583
Sam Saffron Avatar asked Nov 29 '09 22:11

Sam Saffron


People also ask

Does git have a revision number?

Other than that there are no revision numbers in git. You'll have to tag commits yourself if you want more user-friendliness.

How do I find revisions in git?

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.

What is git revision?

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.

What is version number in git?

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.


1 Answers

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.

like image 144
u0b34a0f6ae Avatar answered Oct 04 '22 21:10

u0b34a0f6ae