Does anyone know how to get the latest SHA of a given branch from outside a git repository?
If you are inside a git repository, you can do:
Using a git URL:
$ git ls-remote | head -1 | sed "s/HEAD//"
Using a directory on an accessible system:
$ git --git-dir=/path/to/repo/.git rev-parse origin/