Simple automatic versioning using git

Many times while working on projects its hard to keep track of which version is in staging server, which is on production and which other developers of team are working on, Especially when you are a small startup with limited number of resources. (Its really painful to setup automatic deployment in gitlab).

Here is what i started following in every project :
Version of server should increase with number of commits, major increments will be done manually based on release date, number of issues solved. For automatic commit based versioning add following lines to `.git/hooks/pre-commit`.

`git add Version && echo $(cat Version)+0.0001 | bc | awk ‘{printf “%0.4f”, $0 > “Version”}’`

Also make sure that file is executable by

`chmod +x .git/hooks/pre-commit`

I follow following version numbering system :
– `+1.00000` – Major version
– `+0.1` – Minor Version
– `+0.0001` – Commit

Leave a Reply

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