Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why shouldn't you commit on a tag

Tags:

I'm looking for arguments to convince an customer that he should never commit changes to a tag once it is created.

Common sense appears to be no valid argument so I need something more substantial.

like image 972
B.E. Avatar asked Apr 07 '11 08:04

B.E.


People also ask

Can you commit to a tag?

You can't put a new commit into an existing tag without breaking an important Git guideline: Never(*) modify commits that you have published. Tags in Git aren't meant to be mutable. Once you push a tag out there, leave it alone.

What is the difference between tag and commit?

When it is, a commit will automatically update the master reference to point to that new commit; in other words, branches are mutable references. A tag, on the other hand, is created to point to a specific commit and thereafter does not change, even if the branch moves on. In other words, tags are immutable references.

Why tags are used in git?

Tagging is generally used to capture a point in history that is used for a marked version release (i.e. v1. 0.1). A tag is like a branch that doesn't change. Unlike branches, tags, after being created, have no further history of commits.

Which command creates a lightweight tag?

Sharing Tagsgit push <remote> --tags will push both lightweight and annotated tags. There is currently no option to push only lightweight tags, but if you use git push <remote> --follow-tags only annotated tags will be pushed to the remote.


2 Answers

Tags exist as copies of the sourcecode at a fixed point in time - regardless of whatever changes you might make to the Trunk or any Branch folders, you'll always be able to go back to the code as it was when the tag copy was created.

If you're committing to tagged copies, they no longer represent the source at the point the copy was created - so there's little point having them. Your client should be committing to the trunk, or to branches.

like image 80
Eight-Bit Guru Avatar answered Sep 24 '22 02:09

Eight-Bit Guru


Users who are using the project may be using a certain tagged version of your code. They know their code works with the tag you've specified and will happily release based on this assumption. If you change the tag, then the user's code may break. A tag is literally that - it is a stable milestone on which other user's can consider set in stone.

Also, if there is more than one developer on the project, they'll be working on trunk. When they update, they won't get the changes that were made on the tag which will cause a huge merge problem.

like image 42
EMMERICH Avatar answered Sep 23 '22 02:09

EMMERICH