$ git rev-parse HEAD
# Short version
$ git rev-parse --short HEAD
# Previous commit
$ git rev-parse HEAD~1
$ git rev-parse --abbrev-ref HEAD
# Current branch parent
$ git show -s --format="%H" master^1
# Merged branch parent
$ git show -s --format="%H" master^2
$ git rev-parse --show-toplevel