Abdullah Jibaly
Abdullah Jibaly

Reputation: 54810

Retrieve latest git commit hash of a Github repository without cloning

Is it possible to remotely retrieve the latest commit hash of a Github repo without cloning it locally? I'm referring to something like the following you see at the top of all the repos in Github:

Github Latest Commit

Based on some older questions it seems that this may not be possible with git directly (unless there's a new feature that enables it), so the right answer might involve using the Github API (turns out Github API won't work for my use case since I'll have to use a different set of credentials then the private key git uses).

Upvotes: 4

Views: 1712

Answers (1)

Abdullah Jibaly
Abdullah Jibaly

Reputation: 54810

Found the answer here thanks to @jszakmeister:

git ls-remote $URL HEAD

For my private repo, I had to use the following syntax instead of the URL:

git ls-remote [email protected]:ORG/PROJECT.git HEAD

Upvotes: 9

Related Questions