Reverting a commit

Undoing what a commit did, with a new commit that leaves the history alone.

Reverting undoes what a commit did by making a new commit that applies the opposite changes. Nothing is rewritten: the original stays where it is, and so does everything after it.

That is what makes it the answer on a branch other people also use. Undoing a commit by moving the branch needs a force push; a revert is an ordinary commit and needs an ordinary push.

Revert Commit… is in the header of a commit’s detail, and in the commit’s context menu in the list.

What the revert will do: the commit being undone, the branch the new commit goes on, and how many files it touches.

Open Diff… opens the file list and the changes that would be applied — the commit’s own diff, the other way round. Nothing is written until you press Create Revert Commit, and nothing is pushed.

The message and the signing box

Commit options holds the message Innesta has written for you and a Sign commit box, which starts where your signing setting leaves it. Closing the group again keeps your edits, and so does cancelling: this message is separate from the one in the working copy, so a revert never eats a commit message you were part way through.

If you have uncommitted work

The button reads Stash & Revert instead. Your tracked changes, staged and unstaged, and your untracked files are stashed first and put back afterwards — after an abort as well as after a success, with the staging as it was. Ignored files are left where they are.

Reverting a merge

A merge has two parents, and undoing it means saying which side to keep. Innesta chooses the first — the branch the merge was made into — so the revert undoes what the merge brought in. Compare with, in Commit options, changes that choice. It is not the same as Changes shown in the commit’s header, which changes only what you are reading.

The merge itself stays in the history, and that has a consequence worth knowing before you press the button: merging the same branch again will not bring the changes back, because as far as Git is concerned they are already there. Getting them back means new commits, or reverting the revert.

When it is not offered

Revert Commit… is disabled, and says why, while:

  • you are not on a branch — a detached HEAD has nowhere to put the commit;
  • a merge, rebase or cherry-pick is in progress, or a conflict is unresolved;
  • more than one commit is selected. Revert takes one at a time.

A commit that is not in the checked-out branch’s history opens the sheet and explains itself there, with Create Revert Commit disabled.

If it stops

A revert can stop the way a merge can: on a conflict, on a signing failure, or on a hook that refuses the commit. The status bar then says Revert paused and offers Continue and Abort, and the conflicted files are in the working copy. Their two sides are named Current branch — the file as it is now — and Before reverted commit.

Abort puts everything back, stash included. Ordinary committing waits until you have done one or the other.

When it has finished

The new commit appears in the history and is selected. If a filter is hiding it, the Revert commit created notification offers Show Commit, which clears the filters.

A revert with nothing left to undo creates no commit: Innesta says No changes to revert and closes.