Skip to content

Instantly share code, notes, and snippets.

@wingsum93
Last active July 16, 2019 03:50
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 wingsum93/6af4ad0089ad3bc183357011ff202dce to your computer and use it in GitHub Desktop.
Save wingsum93/6af4ad0089ad3bc183357011ff202dce to your computer and use it in GitHub Desktop.
Change & See the date of a git commit

Set the date of the last commit to the current date

GIT_COMMITTER_DATE="$(date)" git commit --amend --no-edit --date "$(date)"

Set the date of the last commit to an arbitrary date

GIT_COMMITTER_DATE="Tue 16 Jul 2019 12:00:11 HKT" git commit --amend --no-edit --date "Tue 16 Jul 2019 12:00:11 HKT"

Set the date of an arbitrary commit to an arbitrary or current date

Rebase to before said commit and stop for amendment:

git rebase <commit-hash>^ -i
Replace pick with e (edit) on the line with that commit (the first one)
quit the editor (ESC followed by :wq in VIM)
Either:
    GIT_COMMITTER_DATE="$(date)" git commit --amend --no-edit --date "$(date)"
    GIT_COMMITTER_DATE="Tue 16 Jul 2019 12:00:11 HKT" git commit --amend --no-edit --date "Tue 16 Jul 2019 12:00:11 HKT"

ref: https://codewithhugo.com/change-the-date-of-a-git-commit/

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