The Git & Github Bootcamp Part 6 - Master on essentials and the tricky bits: rebasing, squashing, stashing, reflogs, blobs, trees, & more!
Cleaning Up History with Interactive Rebase
1. Introducing Interactive Rebase
Interactive rebase (git rebase -i
) allows you to modify commits in a more controlled manner. It opens a text editor showing a list of commits from the current branch relative to the specified base commit, along with options for how to alter each commit.
2. Rewording Commits With Interactive Rebase
To reword a commit means to change the commit message without altering the snapshot.
- Start an interactive rebase for the last
n
commits:git rebase -i HEAD~n
. - In the editor that opens, change
pick
toreword
(orr
) next to the commit you want to reword. - Save and close the editor. Git will open a new editor window for each commit you chose to reword.
- Update the commit message, save, and close the editor to continue.
Labels: The Git & Github Bootcamp Part 6