Question

In my local repository I have multiple remotes declared. A git fetch --all --tags (requires Git 1.9+) reads like this:

➜  project.git git:(stable-3.0.x) ✗ git fetch --all --tags
Fetching upstream
From github.com:upstream/project
 - [tag update] v3.0.0     -> v3.0.0
Fetching foo
From github.com:foo/project
 - [tag update] v3.0.0     -> v3.0.0
... 

Here is my question: How can I inspect, list and compare the different tags present in my various remotes?

git ls-remote --tags seems to list only the last set of fetched and therefore locally present tags.

Was it helpful?

Solution

There appears to be a long-standing bug in git ls-remote:

$ git ls-remote origin
676699a0e0cdfd97521f3524c763222f1c30a094    HEAD
222c4dd303570d096f0346c3cd1dff6ea2c84f83    refs/heads/branch
676699a0e0cdfd97521f3524c763222f1c30a094    refs/heads/master
d41117433d7b4431a188c0eddec878646bf399c3    refs/tags/tag-foo
$ git ls-remote origin --tags
$ git ls-remote --tags origin
d41117433d7b4431a188c0eddec878646bf399c3    refs/tags/tag-foo

(I found a report about this bug going back to git 1.5.4.) So, it works but only if you use --tags first, then name the remote you wish to contact.

Since ls-remote will only do one remote at a time, you will have to collect up a list of all remotes, then iterate.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top