Skip to content

Instantly share code, notes, and snippets.

@neefrehman
Created December 18, 2018 12:55
Show Gist options
  • Save neefrehman/860dc40ed0d818a3d4ffd67fcc55a515 to your computer and use it in GitHub Desktop.
Save neefrehman/860dc40ed0d818a3d4ffd67fcc55a515 to your computer and use it in GitHub Desktop.
Edit the date of git tags to the dates of the associated commits, while keeping messages for annotated tags
$ git tag -l | while read -r tag ; do COMMIT_HASH=$(git rev-list -1 $tag) COMMIT_MSG=$(git tag -l --format='%(contents)' $tag | head -n1) && GIT_COMMITTER_DATE="$(git show $COMMIT_HASH --format=%aD | head -1)" git tag -a -f $tag -m"$COMMIT_MSG" $COMMIT_HASH ; done
$ git tag -l -n1 #check by listing all tags with first line of message
$ git push --tags --force #push edited tags up to remote
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment