Git Working with Remotes ls-remote

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

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


Got any Git Question?