Reputation: 13996
What is the difference between
git ls-remote --heads origin
and
git ls-remote . "refs/remotes/*"
?
The --heads origin
version takes a while to run, I guess it's updating the references from the origin. The . "refs/remotes/*"
runs instantly.
I'd like to use these lines to git grep remote heads as in the expression below. Which is the right one to use?
git grep "expression" $(git ls-remote . "refs/remotes/*" | grep -v HEAD | cut -f 2)
Is it possible that the --heads origin
can return hashes which are not available locally, thus git-grep wouldn't be able to complete? In this case I guess the right one to use would be . "refs/remotes/*"
with a fetch all first?
Upvotes: 4
Views: 3165
Reputation: 13725
In git ls-remote . "refs/remotes/*"
the dot means you query your local repository to get the data.
As you wrote if you use git ls-remote --heads origin
nobody guarantees that the returned hashes will be accessible locally.
So I think your git fetch
and then using git ls-remote . "refs/remotes/*"
is the safest option.
Upvotes: 4