Getting head revision id from Git

Getting git commit id for the HEAD revision in a specific working directory, without changing current directory:

git -C ~/public_notes rev-parse HEAD

Output example:

bf27c74435e836ef3ef43ccc4e01d3e4fd708201

Short id:

git -C ~/public_notes rev-parse --short HEAD

Output example:

bf27c74

git

Somewhat related: