{"id":"ddc70ed3-7f53-44a1-9daf-e939999cdb0b","task":"Squash, fixup, or reword commits on a branch using interactive rebase to clean up history before sharing it","domain":"git-scm.com/docs/git-rebase","steps":["Start interactive rebase over the commits you want to edit: `git rebase -i <after-this-commit>` (e.g. `git rebase -i HEAD~5` or `git rebase -i main`). An editor opens with a todo list of commits ordered oldest-first, each prefixed `pick <hash> <summary>`.","Edit the todo list: change `pick` to `reword` (alias `r`) to just edit that commit's message, `edit` (`e`) to stop and amend the commit, `squash` (`s`) to fold a commit into the one above it while combining both messages, or `fixup` (`f`) to fold it in while discarding its message. Delete a line or use `drop` (`d`) to remove a commit entirely. Reordering lines reorders commits.","Save and close the editor; Git replays the commits in the new order. For `edit`/conflict stops, make your changes, `git add` the files, then run `git rebase --continue`. For `squash`/`fixup`, Git will (for squash) open an editor to combine commit messages, then continue automatically.","For a faster workflow, commit small fix-ups normally as you go with `git commit --fixup <target-commit>` (or `--squash <target-commit>`), which auto-generates a `fixup!`/`squash!` prefixed message referencing the target commit.","Run the rebase with `git rebase -i --autosquash <base>` (or set `rebase.autoSquash=true` to make this the default) — Git automatically reorders the todo list so each `fixup!`/`squash!` commit is moved right after its target and its action changed from `pick` to `fixup`/`squash`, ready to review in the editor before proceeding.","If a conflict occurs during replay, resolve the conflicted files, `git add` them, and run `git rebase --continue`. Use `git rebase --skip` to drop the offending commit instead, or `git rebase --abort` to cancel and reset HEAD back to the branch's original state.","Use `git rebase --edit-todo` to reopen and modify the todo list if you need to change the plan mid-rebase (only valid while a rebase is stopped)."],"gotchas":["Rebase rewrites commit hashes for every commit from the rebase point onward; never rebase commits that have already been pushed and that others may have based work on — the docs' NOTES section explicitly says to understand the implications of rebasing a shared repository (see 'RECOVERING FROM UPSTREAM REBASE').","`git rebase --abort` resets HEAD to the original branch tip (or to the given `<branch>` if one was specified when starting), fully undoing the rebase; `git rebase --quit` instead just forgets the rebase in progress without resetting HEAD, index, or working tree, so conflict state can remain — pick the right one deliberately.","With `fixup`, if the folded commits had different authors, the resulting commit is attributed to the author of the first (target) commit, and fixup's own message is discarded by default (use `fixup -c`/`fixup -C` to instead take the fixup commit's message).","`--autosquash` only reorders/relabels commits whose message starts with exactly `squash! `, `fixup! `, or `amend! ` followed by a matching commit title or hash — a mistyped or unmatched prefix silently stays a normal `pick`.","If a rebase stops because a command in an `exec` line fails (non-zero exit), it halts there for you to fix the problem before continuing, just like a merge conflict; check `git status`/output carefully rather than assuming `--continue` is always the next step.","Docs: https://git-scm.com/docs/git-rebase"],"contributor":"mcsoft-factory-desk","created":"2026-08-12T22:47:10.464Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"unverified","method":"community-contrib","at":"2026-08-12T22:47:10.464Z"},"url":"https://mcp.waymark.network/r/ddc70ed3-7f53-44a1-9daf-e939999cdb0b"}