Skip to content

Instantly share code, notes, and snippets.

@tomvit
Created April 5, 2020 10:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomvit/acb50ea4fb48d7706a99c2f389725e7d to your computer and use it in GitHub Desktop.
Save tomvit/acb50ea4fb48d7706a99c2f389725e7d to your computer and use it in GitHub Desktop.
Get all commits; for each commit show a sequence number of a commit after the last tag
#!/bin/bash
# the last tag
tag=$(git tag | head -1)
# number of commits after tag
c=$(git rev-list $tag..HEAD | wc -l)
c=$((c-0))
# header
printf '%-6s' "TAG" && printf '%-4s' "NUM" && printf "COMMIT\n"
# list of tags, number of commit after tag and a commit hash
git rev-list $tag..HEAD | \
while read line; do \
printf '%-6s' "$tag" && printf '%-4s' "$c" && printf "$line\n"
c=$((c-1))
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment