I am new to Git.
As far as I know, commit ID is used for identifying individual changes.
Tagging/Labeling is used for identifying the entire state of the repository at a particular point of time.
However, when learning about "Referencing commits" and more specifically on "tree-ish", I encountered the following input:
In Git, tree-ish means something that references part of the tree.
Now in its simplest terms, a tree-ish is a reference to a commit because that commit then in turn references the tree, the Git repository and all the files that are in there at that point.
So if both holds the current state of the repository: what is the difference between the two?
Tag is very similar to commit.
You can look on tags as a human readable commit.
Tag is a pointer the commit it, but instead of remembering the 40 bytes of SHA-1 you refer to it using string ex v1.0 etc. It simply attached human readable string to a SHA-1.
Tag actually store the commit id it pointing to and you can move the tag to different commit by changing the commit id.
The recommended way to use tags is to use the -a flag.
git tag -a
which will create annotated tag. Annotated tag will create a commit like entry for the tag (date, committer, message etc).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With