Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@apaatsio
Created March 4, 2019 09:36
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 apaatsio/a7c6a8b7b2eb4fa53ceb0556c3456ee5 to your computer and use it in GitHub Desktop.
Save apaatsio/a7c6a8b7b2eb4fa53ceb0556c3456ee5 to your computer and use it in GitHub Desktop.
Change any git commit date
# STEP 1
# To change non-root commit
git rebase -i f154548^
# Alternatively, to change the root commit
git rebase -i --root
# STEP 2
# edit the commit you want to change by changing the line
pick f154548 This is a commit message
# to
edit f154548 This is a commit message
# and save&exit
# STEP 3
NEW_DATE="Thu Feb 14 19:59:59 2019 -0800" # custom date
# or alternatively
NEW_DATE="$(date)" # current date
GIT_AUTHOR_DATE="$NEW_DATE" GIT_COMMITTER_DATE="$NEW_DATE" git commit --amend --no-edit --date "$NEW_DATE"
git rebase --continue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment