3

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?

11
  • Cool, I didn't know it was possible to make empty commits. Now I'm wondering why anyone would like to create empty commits, aside from many using them instead of tags… I wonder what was the thought behind the --allow-empty option and its intended usage. Commented Jul 17, 2014 at 15:01
  • @Leif Same here, I learned today that we can create empty commits, and immediately started wondering why you would need tags if you can store the same information in empty commits. Commented Jul 17, 2014 at 15:03
  • With a tag you can write git checkout v1.4. Without a tag you have to find the commit you want and then do git checkout a29bff3 or whatever—much less straightforward. Tools like GitHub also treat tags specially in a similar way. Commented Jul 17, 2014 at 15:03
  • 2
    @Leif Also found a couple of good uses for empty commits here and here Commented Jul 17, 2014 at 15:04
  • @bdesham So other than convenience / intuitiveness / ease of usability, are there any other reasons to use a tag? Commented Jul 17, 2014 at 15:05

1 Answer 1

2

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!

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.