Get revision of remote git repository without checking out

Posted on March 14, 2013

You can get the revision of a remote git repository by using the git ls-remote command

This simple example will output the revision for all branches and tags.

git ls-remote url-to-git-repo:username/repo.git

Output will look something like this:

8eef34582a...        HEAD
4f4d5e18fd...        refs/heads/master
84ae6b827a...        refs/heads/another-branch
...

You can narrow the output down to just one branch by doing the following

git ls-remote url-to-git-repo:username/repo.git branch-name