A tag represents a version of a particular branch at a moment in time. A branch represents a separate thread of development that may run concurrently with other development efforts on the same code base. Changes to a branch may eventually be merged back into another branch to unify them.
From the theoretical point of view:
- tags are symbolic names for a given revision. They always point to the same object (usually: to the same revision); they do not change.
- branches are symbolic names for line of development. New commits are created on top of branch. The branch pointer naturally advances, pointing to newer and newer commits.
From the technical point of view:
- tags reside in refs/tags/ namespace, and can point to tag objects (annotated and optionally GPG signed tags) or directly to commit object (less used lightweight tag for local names), or in very rare cases even to tree object or blob object (e.g. GPG signature).
- branches reside in refs/heads/ namespace, and can point only to commit objects. The HEAD pointer must refer to a branch (symbolic reference) or directly to a commit (detached HEAD or unnamed branch).
- remote-tracking branches reside in refs/remotes/
/ namespace, and follow ordinary branches in remote repository .
git tag <tagname> //create a tag git tag -a <tagname> -m "tag-message" // create an annotated tag // Suggested best practices for git tagging is to prefer annotated tags over lightweight so you can have all the associated meta-data. git tag // list all tags git push origin <tagname> //push one tag git push origin --tags // push all tags //------------------ //first git clone // or git pull //then git checkout tags/<tag_name>