WhiteHotLoveTiger
WhiteHotLoveTiger

Reputation: 2228

git - Determine origin/master without cloning?

Is it possible to get information from a remote git repository without cloning it?

Specifically, can I find out the current commit that a remote's master branch is pointing at, without cloning?

I'd like to do this so that I can loop through a bunch of repos and verify that my builds are all up-to-date in a quick way. I'm thinking that if I can just run a simple command against the remote git server, it would be faster than cloning the whole repository.

Assuming I have valid credentials, or it's a public server, is there something along the lines of:

$ git show ssh://gitserver.com/path/repos/my-great-repo.git origin/master --pretty="%H"

Upvotes: 1

Views: 157

Answers (1)

Moti Korets
Moti Korets

Reputation: 3748

You can use git ls-remote command for that. This will show you remote references with commit ID.
For your case the full command would be
git ls-remote https://gitserver.com/path/repos/my-great-repo.git master

Upvotes: 2

Related Questions