Skip to content

Instantly share code, notes, and snippets.

@mjj2000
Last active June 4, 2024 14:55
Show Gist options
  • Save mjj2000/3ee188cc155c26a118b06116ad0ebd1d to your computer and use it in GitHub Desktop.
Save mjj2000/3ee188cc155c26a118b06116ad0ebd1d to your computer and use it in GitHub Desktop.
[GIT] Get tag of current branch(that is HEAD) or fallback to short commit hash(7 digits) by single shell command
git describe --exact-match --tags 2> /dev/null || git rev-parse --short HEAD
@infogulch
Copy link

Nice, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment