1

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.

3

1 Answer 1

0

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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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