git-name-rev
Describe a commit using existing ref names. tldr-pages
On several platforms
Several platforms
Show the name for HEAD
git name-rev HEADIdentifyShow only the name
git name-rev --name-only HEADIdentifyEnumerate all matching ref names
git name-rev --allIdentifyUse only tags to name the commit
git name-rev --tags HEADIdentifyExit with a non-zero status code instead of printing undefined for unknown commits
git name-rev --no-undefined commit-ishIdentifyShow names for multiple commits
git name-rev HEAD~1 HEAD~2 mainIdentifyRestrict names to branch refs
git name-rev --refs refs/heads/ commit-ishIdentifyRead commit IDs from stdin
echo "commit-ish" | git name-rev --annotate-stdinIdentify