Today I discovered yet again a new gem in git. Think of the following scenario. You have a bunch of 7 commits on your branch and you want to make some modifications to the intermediate commit. This is not uncommon and is a real pain to redo all your work just to modify one intermediate commit. Git provides a unique way to solve this problem using –interactive to git rebase command.
Currently I am on branch Aug23_TOT and I want to modify 4th commit before pushing all my 7 commits.
Commit to be modified
Opens up the editor with the last 7 commits listed and with the default action specified before them.
Make necessary changes to action from the help description below and save and quit the file.
Immediately git rebases first 3 commits as they are specified as ‘picks’ and it stops right next after the first 3 commits and wait for us to make required modifications.
You can make any changes(modify files) to the commit, I am just editing the commit message here. After that, appropriately save your changes back to git commit history using usual git add, git commit commands
After making required changes enter git rebase –continue
Without this interactive rebase feature the task of changing an intermediate commit would be very tedious and time consuming.