![]() ![]() One thing Git does to make this confusing is that it allows you to omit the refs/, and often the word after refs/. But in general, references start with refs/. There are some unusual special-case names that do not begin with refs/: HEAD, ORIG_HEAD, MERGE_HEAD, and CHERRY_PICK_HEAD in particular are all also names that may refer to specific commits (though HEAD normally contains the name of a branch, i.e., contains ref: refs/heads/ branch). The name refs/stash is the stash reference (as used by git stash note the lack of a trailing slash). ![]() A string that starts with refs/heads/ names a branch a string starting with refs/remotes/ names a remote-tracking branch and a string starting with refs/tags/ names a tag. The general form for names for specific commits-which Git calls references-is any string starting with refs/. There are only local tags, so you need to get the tag locally in order to use it. There are no remote tags, though (unless you (re)invent them). There are "remote branches", more properly called "remote-tracking branches", but it's worth noting that these are actually local entities. (It's not clear if the confusion comes because of poor documentation, or the poor documentation comes because this is inherently somewhat confusing, or what.) I point all this out not to be pedantic, 1 but because there is a great deal of confusion about this with casual Git users, and the Git documentation is not very helpful 2 to beginners. There is no such thing as a "remote Git tag". (This answer took a while to write, and codeWizard's answer is correct in aim and essence, but not entirely complete, so I'll post this anyway.) Reachable tags (an ancestor) from the current branch (located on the history)įrom Git 2.4 you can set it using configuration $ git config -global push.followTags true.Annotated tags (so you can skip local/temp build tags).This flag -follow-tags pushes both commits and only tags that are both: To push annotated tags and current history chain tags use: git push -follow-tags It's recommended to use refs/tags since sometimes tags can have the same name as your branches and a simple git push will push the branch instead of the tag.Using the refs/tags instead of just specifying the. ![]() branch can also take tags and detaches the HEAD at that commit in the resulting repository. 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. ![]()
0 Comments
Leave a Reply. |