Real, Everyday Messy Work
git commit -m "WIP"
git commit -m "WIP"
git commit -m "WIP"
git commit -m "WIP"
Four real commits, all "WIP" — completely normal mid-feature history nobody should ever see in a PR.
A Real Interactive Rebase, Without a Real Editor
GIT_SEQUENCE_EDITOR="sed -i '2,4s/^pick/squash/'" \
GIT_EDITOR="sed -i '1s/.*/Add recipe search feature/'" \
git rebase -i HEAD~4
GIT_SEQUENCE_EDITOR runs a real sed command against the real todo list git generates — marking commits 2 through 4 as squash instead of opening an editor to do it by hand. GIT_EDITOR does the same for the combined commit message that follows.
Squash vs. Fixup: A Real, Direct Contrast
git commit -m "fix typo in search description"
GIT_SEQUENCE_EDITOR="sed -i '2s/^pick/fixup/'" git rebase -i HEAD~2
squash keeps and lets you combine both real messages; fixup silently discards the fixup commit's own message, keeping only the target's. The real, final history looks exactly as if the typo had never happened.
A real feature branch, four honest "WIP" commits deep — normal, everyday, unglamorous work. Before opening a PR, a reviewer should see one real, meaningful commit, not the messy real process that produced it.
git rebase -i is genuinely interactive by design — it opens a real text editor showing a "todo list" of commits, letting you mark each one pick, squash, fixup, edit, or reword. This sandbox has no real text editor available (core.editor is set to true, a real, permanent fix from Block 2.4). Rather than fake the interactivity, this lesson uses the real, genuine technique professional teams use for scripted rebases: GIT_SEQUENCE_EDITOR runs a real command against the todo list instead of opening an editor, and GIT_EDITOR does the same for the resulting commit message.
GIT_SEQUENCE_EDITOR
An environment variable that, when set, replaces the real editor git would normally open for an interactive rebase's todo list with a real command of your choosing. Confirmed directly in this lab: a plain sed one-liner genuinely rewrote "pick" to "squash" without any real editor session.
squash vs. fixup
Both meld a commit into the one before it — squash keeps both real messages and lets you combine them; fixup silently discards the fixup commit's own message. Confirmed directly in this lab: the fixup commit's "fix typo in search description" message never appears anywhere in the final real history.
Takeaways
- GIT_SEQUENCE_EDITOR scripts a real interactive rebase's todo list without opening an editor
- GIT_EDITOR does the same for the resulting commit message
- squash keeps and lets you combine real commit messages; fixup silently discards the fixup commit's own message
- This sandbox's lack of a real editor is not a limitation being faked around — GIT_SEQUENCE_EDITOR is genuine, first-class automation tooling