From within Git repository:
$ cd /path/to/git/repo
$ git rev-parse HEAD
c8f882b484eeb71068539fd02f04c5c2eada1c02
Fetch another branch/tag SHA-1:
$ cd /path/to/git/repo
$ git rev-parse BRANCH_OR_TAG
c8f882b484eeb71068539fd02f04c5c2eada1c02
Can also fetch SHA-1 from a path outside of Git repository (handy for scripting):
$ git --git-dir=/path/to/git/repo/.git rev-parse HEAD
c8f882b484eeb71068539fd02f04c5c2eada1c02
$ git --git-dir /path/to/git/repo/.git log -1 --pretty=format:%H HEAD
c8f882b484eeb71068539fd02f04c5c2eada1c02