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:
Heres a copy-paste solution which works inside the repository.
origin_head=$(git ls-remote --heads $(git config --get remote.origin.url) | grep "refs/heads/master" | cut -f 1) if [ $origin_head != "$(git rev-parse HEAD)" ]; then echo >&2 "HEAD and origin/master differ." exit 1 fi