How to create Git tags from an older commit

  • 20th Mar 2024
  • 1 min read
  • Tags: 
  • git
  • Set the git HEAD to the old commit that we want to tag.
git checkout <COMMIT_HASH>
  • Temporarily set the date to the date of the HEAD commit, and add the tag
GIT_COMMITTER_DATE="$(git show --format=%aD | head -1)" \
git tag -a <TAG> -m<TAG MESSAGE>
  • Push to origin
git push origin --tags
  • Set the git HEAD back to whatever you want it to be
git checkout master