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.
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.
Sign up to join this communitySolution 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.
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
u
? That works for me.