Another interesting concept in git are commit pointers,
in git these are called tags
A tag identifies a specific commit with a meaningful name, replacing the complicated hash
Tags are used to identify a commit as a significant one
e.g. tags could be used to identify the commit of a specific release of a program
git tag <tag_name> [<commit_hash>]
The command tag requires a name for the tag and optionally the hash of the commit which has to be tagged (If no hash is provided the "last" commit will be tagged)
n.b. tag name must be short and simple,-m
, followed by the message
Tag a specific commit
git tag v1.2.0 be4f621
A pointer is added to the commit with the specified name
Simply using
git tag
v1.0
v1.1.1
v1.2.0
(END)
tag without parameters returns the list of the repository tags
As we said earlier each commit has a pointer to its parent, so we can see the entire history of a git repo like a collection of commits and commit pointers
We used an intuitive meaning of branch for simplicity, but in the real git the branches are really similar to commit pointers
In particular branch is a pointer to the last commit of the "intuitive branch"
HEAD is a special tag pointing the current working branch
in an ordinary situation
To do this we can use the command checkout with the hash of the commit we want move HEAD to
git checkout <commit_hash>