How do I undo my last commit?

Undo it while it is still only on your Mac, amend it, or revert it once it has been pushed.

Right after you commit, Undo Commit appears beside the Commit heading, with the commit’s subject. Press it and the commit comes off the branch, its changes staged again. Nothing else in your working copy changes, and if the message field is empty it gets the commit’s message back.

After five seconds the button shrinks to an arrow, and it stays there until something else changes the repository: another commit, another operation, or closing the repository.

The arrow beside Commit undoes the commit just made. For its first five seconds it is spelled out, with the commit's subject.

Once you have undone it, the same place offers Redo Commit, which puts back the very same commit: the same hash, author, message and signature.

From History

Undo Commit…, in a commit’s context menu in History, undoes the latest commit on the branch you are on, after a confirmation. When that commit can be undone it is also under the arrow beside Revert Commit…, in the commit’s header. That is the way in for a commit made outside Innesta, or once the arrow in the commit panel has gone.

When it cannot be undone

Only the latest commit on the branch you are on can be undone, and not when:

  • a remote branch already has it — revert it instead, which adds a commit rather than removing one;
  • it is a merge — revert that too;
  • you are not on a branch, a conflict is unresolved, or another operation is under way.

An undone commit is kept for as long as Keep recovery backups in Settings says, so after the arrow has gone it can still be found in the reflog.

“The commit is right, one detail is wrong”

Amend it. The button under the commit message field opens a review with an editable message and the staged files to include. Leave the Working Copy message field empty to start from the existing message, then edit it in the review. The commit is replaced when you confirm.

Further back, or without the changes

Hard Reset to Commit…, in the context menu of an older commit in History, moves the branch back to it and throws away everything after it, uncommitted changes to tracked files included. Innesta previews what would change, asks for a typed confirmation, and takes a restore backup first, so this is recoverable from Recovery for as long as the backup is kept.