Edit the contents of a past Git commit while preserving subsequent commits.
Steps
- Start the rebase from the parent of the commit you want to edit:
- In the editor, change
pick
toedit
for your commit:
pick abc1234 Earlier commit
edit def5678 The commit to modify
pick ghi9012 Later commit
- Make your changes:
- Finish the rebase:
Recovery
If anything goes wrong:
But be aware that this will lose any changes you made during the rebase.