Docs

Rewriting history

Select a commit on the map and press one key. Since rewrites the commit and replays every commit after it on the current branch for you. No editor and no todo list.

The actions

ActionKeyWhat happens
Edit messageEOpens the full message for editing. Save to reword the commit.
Squash with parentSCombines the commit with its parent and keeps both messages.
Fixup with parentFCombines the commit with its parent and keeps only the parent's message.
Split commit⇧SPick the lines that go into each new commit and give each one a message. Merge commits can't be split.
Swap with parent••• menuSwaps the order of the commit and its parent.
Delete commit⌫Removes the commit's changes from the branch.
The commit menu with its Rewrite section: Edit Message, Squash, Fixup, Swap with Parent and Delete CommitThe commit menu with its Rewrite section: Edit Message, Squash, Fixup, Swap with Parent and Delete Commit

Moving commits between branches

Rebase the current branch onto the selected commitR
Merge the selected commit into the current branchM
Cherry-pick the selected commit onto the current branchP
Revert the selected commitV

To point the current branch at another commit, choose Move “branch” here in the commit's ••• menu.

If you change your mind

Every rewrite is one step on the undo stack. ⌘Z puts the branch back exactly as it was, and ⇧⌘Z does it again. See Undo and redo.

Limits

  • The commit has to be on the current branch. To rewrite a commit on another branch, check that branch out first.
  • Merge commits can't be rewritten, and neither can history that has a merge between the commit and HEAD, because replaying it would flatten the merge.
  • Squash, fixup and swap need a parent, so they don't apply to the first commit in the repository.
  • Uncommitted changes are set aside during the rewrite and put back afterwards.
  • Rewriting commits you have already pushed means the next push has to be a force push. Since asks before force pushing, and uses --force-with-lease so it won't overwrite someone else's new work.