Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Will a commit be garbage collected if it's referred to by tag but not by branch?

Tags:

I've got an annotated tag referring to a commit (does it matter if it is annotated?) and no branch referring there. Will the commit be garbage collected after some time?

like image 542
Adrian Panasiuk Avatar asked Jun 28 '09 21:06

Adrian Panasiuk


People also ask

When would a git commit get garbage collected?

Garbage collection in interpreted languages is used to recover memory that has become inaccessible to the executing program. Git repositories accumulate various types of garbage. One type of Git garbage is orphaned or inaccessible commits.

Does deleting a git tag delete the commit?

No, because the commit is still referenced by tag t .

What does the tag do to your commit?

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.

Is a tag specific to a branch?

Tags and branch are completely unrelated, since tags refer to a specific commit, and branch is a moving reference to the last commit of a history. Branches go, tags stay.


2 Answers

No, the commit will not be garbage collected. A reference from a tag is sufficient to keep a commit alive.

like image 50
Greg Hewgill Avatar answered Oct 12 '22 23:10

Greg Hewgill


tags and branches are both refs, if a ref is pointing to a commit, it's not garbage collected. You can also have custom refs, but those are uncommon.

like image 30
FelipeC Avatar answered Oct 13 '22 01:10

FelipeC