Interview Prep/Git & GitHub/Merge and Rebase Problems

`git rebase -i` fails with `error: invalid line 3: ...` or the todo list says `Nothing to do`.

IntermediateTroubleshootingMerge and Rebase Problems
Answer

Likely causes → You edited a line into an invalid command (typo, missing SHA, extra text), or the range contains no commits (you passed the wrong base, or HEAD equals the base).

Diagnose →

git log --oneline origin/main..HEAD     # what the range contains
git rebase --edit-todo                  # reopen the todo list

Fix → Use valid commands (pick, reword, edit, squash, fixup, drop, exec). If the list is empty, pass the correct base, e.g. git rebase -i HEAD~5 or --root. Deleting every line aborts the rebase.

Prevent → Do not delete lines to drop commits; use drop.

All Git & GitHub questions Roadmap: Git & GitHub

More on Merge and Rebase Problems