Intermediate LevelGit & GitHub
How do you perform Interactive Rebasing to squash and reorder commits?
❓ Interview Prompt: Explain git rebase -i HEAD~N, interactive rebase commands (pick, reword, edit, squash, fixup, drop), and cleaning feature branch history.
git rebase -i HEAD~N opens an interactive editor allowing you to clean up commit history. Use pick to keep, reword to edit message, squash to combine commits, fixup to combine and discard message, and drop to delete commits.
Code Implementation Example
bash
# Interactive rebase todo list:
pick a1b2c3d feat(auth): add login route
fixup e5f6g7h fix typo in login route
squash 9i8h7g6 test(auth): add unit test for login💡Cleaning commit history using interactive rebase commands (pick, fixup, squash).
🎯 Interview Key Takeaway
Use git rebase -i to squash WIP commits, fix typos with fixup, and reword commit messages before merging.
#git rebase -i#Squash#Fixup#Intermediate
Back to all Git & GitHub Questions→