Ram Rachum Ram Rachum - 3 months ago 36
Git Question

Git: Find which commit is checked out on a remote

I have a local repo, and this repo has a remote. I want to know which commit (by SHA number) is checked out on the remote, assuming the remote is not a bare repository.

Clarification: I don't want anything to do with tracking branches or any other kind of branches on my local repository. In fact I want a method that works even if my local repository is a bare repository. Imagine that my remote is

, so I want to get the equivalent of SSHing into the server
, doing
cd /foo
git rev-parse HEAD

I don't want to do the above example directly because I can't guarantee that I'll have SSH access to the remote. I want a method that works regardless of the type of remote

I want the response to be a SHA, not a branch name

git ls-remote origin HEAD

(any repo reference will do for origin, you can used a url or a path)