What is the difference between running git ls-remote and git ls-remote origin? It appears git ls-remote outputs the SHA1 IDs of each branch and tag of the original repository. Since the original repo is by default titled origin, it appears that these two commands yield the same output. Is this correct?
Although the git ls-remote manual page fails to mention this, the default argument computation here is the same as that for git fetch, whose documentation is more explicit:
When no remote is specified, by default the
originremote will be used, unless there’s an upstream branch configured for the current branch.
What this means is that if you have multiple remotes defined (e.g., origin and second) and you are on branch B with branch.B.remote set to second, running git ls-remote without any arguments is now equivalent to running git ls-remote second. If you are on a more typical branch, with branch.branch.remote set to origin or not set at all, running git ls-remote without specifying a particular remote is equivalent to running git ls-remote origin.
You're correct. Because your remote is called origin there's no difference between the two commands.
To see all your git remotes, run git remote -v.
On the other hand, if your remote was called foobar then git ls-remote origin would give you this error:
$ git ls-remote origin
fatal: 'origin' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With