git ls-remote
is one unique command allowing you to query a remote repo without having to clone/fetch it first.
It will list refs/heads and refs/tags of said remote repo.
You will see sometimes refs/tags/v0.1.6
and refs/tags/v0.1.6^{}
: the ^{}
to list the dereferenced annotated tag (ie the commit that tag is pointing to)
Since git 2.8 (March 2016), you can avoid that double entry for a tag, and list directly those dereferenced tags with:
git ls-remote --ref
It can also help resolve the actual url used by a remote repo when you have "url.<base>.insteadOf
" config setting.
If git remote --get-url <aremotename>
returns https://server.com/user/repo, and you have set git config url.ssh://[email protected]:.insteadOf https://server.com/
:
git ls-remote --get-url <aremotename>
ssh://[email protected]:user/repo