Useful for altering one or multiple commits. Squashing them into a single commit etc.
git commit rebase -i <commithash>
Commit History: A-B-C-D-E-F
where F
is HEAD
git rebase -i <commithash>
- Where commit hash is a commit before the commits you want to alter.
- To change
C
, andE
use<commithash>
ofB
- To make changes to
A
usegit rebase -i --root
- Change the lines for all commits to edit from
pick
toedit
- This change is to be made in the editor opened via git.
- Close it to continue
- Rebase will then stop at all commits to edit
- Run required edit command
git commit --amend --author="New Guy"
- Run multiple commands as required
- Continue rebase with
git rebase ---continue
- Run required edit command
- After all commits have been edited using the above push to update origin
git push -f