Interactive Rebase

Rewriting a Branch with Interactive Rebase

git rebase -i main first writes a todo list, one line per commit, oldest first, and opens it in the editor named by GIT_SEQUENCE_EDITOR (or core.editor). Setting that to cat prints the list you would see, with its help text on the commands reword, edit, squash, fixup, exec and more, then runs it unchanged:

Printing the todo list of an interactive rebaseShell
GIT_SEQUENCE_EDITOR=cat git rebase -i main
Output
pick 1ed7071 # Add ?limit= to /api/books
pick 5341b2a # wip
pick 3e5bc80 # Fix limit typo
# Rebase e78d7c2..3e5bc80 onto e78d7c2 (3 commands)
#
# Commands:
# p, pick <commit> = use commit
...
# d, drop <commit> = remove commit
...
Successfully rebased and updated refs/heads/paginate-api.

An unchanged list rewrites nothing. Edit it by changing command words and reordering lines: move the typo fix under its commit as a fixup, which melds it in and drops its message, and mark "wip" edit to split it next. Copying a saved list over Git 1,932 's makes the same edit:

Running an edited todo listShell
cat > ../todo.txt <<'EOF'
pick 1ed7071 # Add ?limit= to /api/books
fixup 3e5bc80 # Fix limit typo
edit 5341b2a # wip
EOF
GIT_SEQUENCE_EDITOR="cp ../todo.txt" git rebase -i main
Output
Stopped at 5341b2a...  # wip
You can amend the commit now, with
...
  git rebase --continue

Git folded the fix into the limit commit, applied "wip" and stopped there. reword stops only to edit a message, drop removes a commit, and an exec npm 2,036 test line stops the rebase if the tests fail at that point.