I can print the current git commit sha1 in bash using this command:

git rev-parse --short HEAD

But how can I print only the latest commit message/title of the HEAD?


I quite like

git show --oneline -s HEAD

If you only want to see the message, use

git show --pretty=format:%s -s HEAD

instead. To add the SHA-1:

git show --pretty=format:"%H %s" -s HEAD

(or %h for the abbreviated SHA-1).

See the git show documentation for details.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.