dromodel
dromodel

Reputation: 10203

Are Git tags and branches versioned?

Subversion represented tags and branches in the repository, allowing you to manipulate and version them. This was a useful property for long lived repositories as you might want to reuse a tag or branch name. You could delete the branch and recreate it and if you wanted to see the old one then you just checked out an older version of the repository. With Git, it seems like once you delete it all you have left is the hash and no record that there used to be a tag or branch with some name pointing to it. Is that correct?

Upvotes: 0

Views: 121

Answers (2)

Tim Henigan
Tim Henigan

Reputation: 62168

The short answer is that neither tags nor branches are versioned. However, you should read the "On Re-Tagging" section of the git tag man page.

If you change a tag that has already been made public, it will cause problems since git will not change a tag out from under a user. For example:

  1. Bob creates tag v1.0
  2. Alice pulls tag from Bob
  3. Bob forces the tag for v1.0 to a different commit
  4. The next time Alice pulls from Bob, she will not get the modified tag!

If Alice really needs the new tag, she must:

  1. git tag -d v1.0
  2. Pull the tag from Bob again

Upvotes: 0

Mot
Mot

Reputation: 29560

No, Git tags and branches are not versioned. Both are just pointers to commits. In contrast to Hg where the tags are tracked in a working tree file (.hgtags), in Git they are stored in the admin are (.git directory).

Upvotes: 3

Related Questions