Git Rebase Interactive
What I Learned
Git’s interactive rebase (git rebase -i) is a powerful tool for cleaning up commit history before pushing changes. It allows you to reorder, squash, edit, or remove commits.
Details
Interactive rebase opens an editor with a list of commits and commands:
1git rebase -i HEAD~3
Available commands:
pick- use commit as-isreword- change commit messageedit- stop for amendingsquash- combine with previous commitfixup- like squash but discard commit messagedrop- remove commit
Example workflow:
pick abc1234 Add feature X
squash def5678 Fix typo in feature X
reword ghi9012 Update documentation
This creates a cleaner history by combining related commits and improving commit messages.