How to Do Interactive Rebase in Git?

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.

Current branch with above said 7 commits
Current branch with above said 7 commits

Commit to be modified

Commit to be modified
Commit to be modified
Interactive rebasing of last 7 commits
Interactive rebasing of last 7 commits( git rebase -i )

Opens up the editor with the last 7 commits listed and with the default action specified before them.

Rebase editor to choose from commits to modify
Rebase editor to choose from commits to modify

Make necessary changes to action from the help description below and save and quit the file.

Change 'pick' to 'edit' to tell git which commit need to be edited
Change ‘pick’ to ‘edit’ to tell git which commit need to be edited

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.

Git stops after rebasing first 3 commits
Git stops after rebasing first 3 commits

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

Here in 4th commit I am updating the commit message
Here in 4th commit I am updating the commit message

After making required changes enter git rebase –continue

Tell git to continue further with remaining commits
Tell git to continue further with remaining commits
Final changes
Final changes

Without this interactive rebase feature the task of changing an intermediate commit would be very tedious and time consuming.