Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the advantage of using a git tag over an empty commit in git?

This question arises more out of curiosity and not due to issues faced while using git.

git allows you to make empty commits with git commit -m "message" --allow-empty

You can also tag specific revisions using git tag -a v1.4 -m 'my version 1.4'.

For all practical purposes I can think of right now, like making a tag to signify an important commit, deploying a particular tag, creating tag to specify version bumps, we can create an empty commit with the same message and then use it instead of the tag.

So, what is the advantage of using tags over empty commits, and vice versa?

like image 677
Anshul Goyal Avatar asked Dec 18 '25 01:12

Anshul Goyal


1 Answers

You can immediately checkout a tag. E.g. after deploy to production you do something like

git tag -f production

and if you ever need to test something, as it is deployed, you can do

git checkout production

Also, extra advantage: no empty commits!

like image 159
nathanvda Avatar answered Dec 20 '25 17:12

nathanvda



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!