Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save neharkarvishal/e3fec2274d454acb389bc3052b7dff70 to your computer and use it in GitHub Desktop.
Save neharkarvishal/e3fec2274d454acb389bc3052b7dff70 to your computer and use it in GitHub Desktop.

This walks you through making your last 4 commits look like freshly made commits, with new timestamps and commit hashes.

Step 1: Start Interactive Rebase

git rebase -i HEAD~4

In the editor that opens, change all pick to edit like so:

edit abc123 Commit message 1
edit def456 Commit message 2
edit ghi789 Commit message 3
edit jkl012 Commit message 4

Save and close the editor.

Then, for each commit, Git will pause and let you amend it. Run the following:

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

Repeat for each of the 4 commits.

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