
#Git checkout tag example how to#
Git knows how to "translate" the given SHA-1 to the relevant commit # Clone a specific tag name using git clone Since git supports shallow clone by adding the -branch to the clone command we can use the tag name instead of the branch name. Option 1: # Update the local git repo with the latest tags from all remotes

As explained above tags are like any other commits so we can use checkout and instead of using the SHA-1 simply replacing it with the tag_name In order to grab the content of a given tag, you can use the checkout command. Note: If you try to delete a non existig Git tag, there will be see the following error: $ git tag -d ĭelete remote tags # Delete a tag from the server with push tags How to delete tags? Delete a local tag $ git tag -d The difference between the 2 is that when creating an annotated tag you can add metadata as you have in a git commit: There are 2 ways to create a tag: # lightweight tag

# list all tags with given pattern ex: v. How to see the list of all tags? # list all tags Īll of the above will do the same since the tag is only a pointer to a given commit. In this sample you have 2 tags version 1.0 & version 1.1 you can check them out with any of the following: $ git checkout A. Then check out the tag by running $ git checkout tags/ -b You will not be able to checkout the tags if it's not locally in your repository so first, you have to fetch the tags to your local repository.įirst, make sure that the tag exists locally by doing # -all will fetch all the remotes. It points directly to a specific commit in the history and will not change unless explicitly updated. v1.0, etc.).Īlthough a tag may appear similar to a branch, a tag, however, does not change. It is usually used to mark release points (eg. Let's start by explaining what a tag in git isĪ tag is used to label and mark a specific commit in the history.
