Skip to content

Instantly share code, notes, and snippets.

@copyleftdev
Created May 25, 2026 20:21
Show Gist options
  • Select an option

  • Save copyleftdev/e6cb7c8e362230c7d60271240ae3298c to your computer and use it in GitHub Desktop.

Select an option

Save copyleftdev/e6cb7c8e362230c7d60271240ae3298c to your computer and use it in GitHub Desktop.
git commit --fixup and git rebase --autosquash
# git commit --fixup + git rebase --autosquash
# Fix any past commit cleanly — no painful interactive rebase editing.
# Spot a typo in the third commit back:
git add the-fix.rs
git commit --fixup HEAD~2
# creates: "fixup! <original commit message>"
# Let autosquash reorder + squash automatically:
git rebase -i --autosquash main
# The fixup is already placed below its target in the todo list.
# Just save and close — no editing needed.
# ── Make this the default globally ────────────────────────────
git config --global rebase.autoSquash true
# Now plain `git rebase -i` always applies autosquash behaviour.
# ── fixup! vs squash! ─────────────────────────────────────────
# --fixup → silently squashes, keeps original message
# --squash → squashes and opens editor to combine messages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment