If I accidentally staged a hunk that I wanted a better look at, how do I undo that action (the most recent action). C-/ does not work.

Sure I can U to unstage all, but say all else staged is valid.


1 Answer 1


Solution 1,

M-x magit-unstage

Solution 2:

Any commit/patch/diff could be opened in diff-mode. Then M-x diff-apply-hunk to apply hunk. C-u M-x diff-apply-hunk to undo hunk.

Actually, you don't need switch to diff-mode from magit-revision-mode at all, simple diff-apply-hunk is enough.

Extra tip:

If you use smex or counsel-M-x from counsel, when you type M-x some-keyword, all related commands are displayed.

enter image description here

As you can see, there are other commands to upstage/undo a hunk.

  • magit-unstage does not automatically undo the last staged hunk. Jan 16, 2022 at 19:13
  • No, there's no "undo" (to my knowledge); you must manually unstage it.
    – phils
    Jan 17, 2022 at 4:51

Your Answer

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

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