You can use git rev-parse for this. It can accept anything that looks even remotely like a commit, and returns the full SHA1 hash for that commit.
For example, to get SHA1 from HEAD :
git rev-parse HEAD
To get SHA1 from master :
git rev-parse master
To get SHA1 from origin/trunk :
git rev-parse origin/trunk
To get the SHA1 of all the remote heads (this is just one of many ways to do this and, of course, not the best):
git branch -r | cut -d' ' -f 3 | while read remote; do echo ${remote} `git rev-parse ${remote}` done
JΓΆrg W Mittag
source share