9

In the magit from spacemacs, when I press O on a commit, it shows several actions, two of them are "revert commit" and "revert change", what's the difference between them?

1
  • (Without being a magit expert) I'd say that reverting a change simply restores your local files to the original state, whereas reverting a commit creates a new change set that undoes the effect of a previous commit. Commented Jan 21, 2016 at 9:19

1 Answer 1

14

According to the magit documentation, Revert changes does the following:

Revert COMMIT by applying it in reverse to the worktree. Prompt for a commit, defaulting to the commit at point. If the region selects multiple commits, then revert all of them, without prompting.

The git command that it runs under the hood is git revert --no-commit COMMIT where COMMIT is the commit you selected.

As for Revert commit(s):

Revert COMMIT by creating a new commit. Prompt for a commit, defaulting to the commit at point. If the region selects multiple commits, then revert all of them, without prompting.

For this, the git command that gets run is git revert COMMIT.

In other words, reverting changes puts the changes from the selected commit back in the working tree for you to do what you want with (including commit again), while reverting a commit will undo the changes from the selected commit and create a new commit (i.e., a new commit where those changes have been undone).

Also, whenever you see options in a magit popup, you can hit ? and then the key associated with an option to see the documentation for that option.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.