How to see remote tags?
Asked Answered
H

2

249

In Atlassian SourceTree, how to know which tags are only local and which are also in remote?

When creating a tag you get the option "Push tag to: ...", but how to know if a tag has been pushed or not after it is created? I can see all my tags locally, but I need to be sure that they are present in remote so that other developers can pull them.

Hubris answered 22/9, 2014 at 22:56 Comment(2)
I have updated my answer below to address Atlassian SourceTree specifically.Fernandez
In case someone is looking for something similar for GitHub https://mcmap.net/q/118816/-git-ls-remote-tags-how-to-get-date-informationPerseus
F
181

Even without cloning or fetching, you can check the list of tags on the upstream repo with git ls-remote:

git ls-remote --tags /url/to/upstream/repo

(as illustrated in "When listing git-ls-remote why there's “^{}” after the tag name?")

xbmono illustrates in the comments that quotes are needed:

git ls-remote --tags /some/url/to/repo "refs/tags/MyTag^{}"

Note that you can always push your commits and tags in one command with (git 1.8.3+, April 2013):

git push --follow-tags

See Push git commits & tags simultaneously.


Regarding Atlassian SourceTree specifically:

Note that, from this thread, SourceTree ONLY shows local tags.

There is an RFE (Request for Enhancement) logged in SRCTREEWIN-4015 since Dec. 2015.

A simple workaround:

see a list of only unpushed tags?

git push --tags

or check the "Push all tags" box on the "Push" dialog box, all tags will be pushed to your remote.

https://static.mcmap.net/file/mcmap/ZG-AbGLDKwfjaR0tcV2pcGkQW7-sW7MxZV_QKmMva3/tnckb94959/attachments/tnckb94959/sourcetree-questions/10923/1/Screen%20Shot%202015-12-15%20at%208.49.48%20AM.png

That way, you will be "sure that they are present in remote so that other developers can pull them".

Fernandez answered 23/9, 2014 at 6:6 Comment(6)
That's great but I was asking about how to know it with Atlassian SourceTree, not git command line.Hubris
git push --tags vs git push --follow-tagsWhitford
I tried refs/tags/MyTag^{} to get commit id linked to that tag but this command git ls-remote doesn't return anything. Is there any way to get the commit id of a dereferenced tag?Defeatism
@Defeatism This should be https://mcmap.net/q/14136/-what-does-mean-in-gitFernandez
@Fernandez Thanks. The post is not remote git command. I need the commit id without checking out the code... But thanks I just found out that my command line needed double quotes for the dereferenced tag; so this worked perfectly: git ls-remote --tags /some/url/to/repo "refs/tags/MyTag^{}"Defeatism
@Defeatism Good catch! I have included your comment in the answer for more visibility.Fernandez
U
285

You can list the tags on remote repository with ls-remote, and then check if it's there. Supposing the remote reference name is origin in the following.

git ls-remote --tags origin

And you can list tags local with tag.

git tag

You can compare the results manually or in script.

Unwonted answered 23/9, 2014 at 6:8 Comment(7)
No problem: that is how I have been learning Git since late 2008.Fernandez
That's great but I was asking about how to know it with Atlassian SourceTree, not git command line.Hubris
@Hubris So you were asking whether Atlassian SourceTree provides the feature to view the remote tags in GUI, right? I have a rough look, and it seems not. But why not just click on the menu Actions -> Open in Terminal, and then type git ls-remote --tags origin and run?Unwonted
You should change the name of the question to address Source Tree, because it is very misleadingValarievalda
@Unwonted Thanks, that's useful. When listing remote tags, I'm seeing double entries. They have diff ID but same tag name except with postfix ^{}. Example: release-v1.0, release-v1.0^{}, release-v1.1, release-v1.1^{}, etc.. Do you know what those extra entries are? Although the extra entries have diff ID, git log <ID> gives the same output though.Enlil
@Enlil That means the tag is annotated. When you create an annotated tag git creates another commit that points to the original commit. The original commit is represented by the brackets at the end.Hosiery
cool thats git's "intuitive" command line. The answer was helpful but just wondering now nearly a decade later: Isn't there an alternative that has less potential cultivating new git hater offspring's? I mean sth. like 'git tag --remote' or at least 'git ls-local'Fiord
F
181

Even without cloning or fetching, you can check the list of tags on the upstream repo with git ls-remote:

git ls-remote --tags /url/to/upstream/repo

(as illustrated in "When listing git-ls-remote why there's “^{}” after the tag name?")

xbmono illustrates in the comments that quotes are needed:

git ls-remote --tags /some/url/to/repo "refs/tags/MyTag^{}"

Note that you can always push your commits and tags in one command with (git 1.8.3+, April 2013):

git push --follow-tags

See Push git commits & tags simultaneously.


Regarding Atlassian SourceTree specifically:

Note that, from this thread, SourceTree ONLY shows local tags.

There is an RFE (Request for Enhancement) logged in SRCTREEWIN-4015 since Dec. 2015.

A simple workaround:

see a list of only unpushed tags?

git push --tags

or check the "Push all tags" box on the "Push" dialog box, all tags will be pushed to your remote.

https://static.mcmap.net/file/mcmap/ZG-AbGLDKwfjaR0tcV2pcGkQW7-sW7MxZV_QKmMva3/tnckb94959/attachments/tnckb94959/sourcetree-questions/10923/1/Screen%20Shot%202015-12-15%20at%208.49.48%20AM.png

That way, you will be "sure that they are present in remote so that other developers can pull them".

Fernandez answered 23/9, 2014 at 6:6 Comment(6)
That's great but I was asking about how to know it with Atlassian SourceTree, not git command line.Hubris
git push --tags vs git push --follow-tagsWhitford
I tried refs/tags/MyTag^{} to get commit id linked to that tag but this command git ls-remote doesn't return anything. Is there any way to get the commit id of a dereferenced tag?Defeatism
@Defeatism This should be https://mcmap.net/q/14136/-what-does-mean-in-gitFernandez
@Fernandez Thanks. The post is not remote git command. I need the commit id without checking out the code... But thanks I just found out that my command line needed double quotes for the dereferenced tag; so this worked perfectly: git ls-remote --tags /some/url/to/repo "refs/tags/MyTag^{}"Defeatism
@Defeatism Good catch! I have included your comment in the answer for more visibility.Fernandez

© 2022 - 2024 — McMap. All rights reserved.