I know how to get to a diff from an older commit: get to *magit-log*
, and "click" on the commit. How to get a particular change in the diff applied in reverse? I want it to just modify the file (and buffer, if open).
How to revert a change from older commit in `magit`?
I was going to offer a way to do it in vc mode, but this question caused me to discover exactly what you want(I think)
Move your point to the change you want to revert and type v (magit-revert-item)
If you then go to magit-status window you will see that there is an unstaged change with the reverse of the change.
That's way easier than the vc-mode way which is to C-c C-r (diff-reverse-direction) and then C-c C-a (diff-apply-hunk).
Either one is pretty darned handy IMO
And like other magit functions, you can do this for just the marked region if necessary. You may or may not need to ensure point is inside the region (this at least used to be necessary for staging or unstaging regions).
C-x C-x
if you marked it the 'wrong' way around. –
Aretha lukstafi:
C-h m
C-s revert
? –
Aretha I believe this should be a capital
V
? More specifically V v
as described at magit.vc/manual/magit/Reverting.html? –
Kolk @Kolk in the magit rev mode which you get to from magit log the shortcuts now are
_
and then theres a bunch of options but the relevant one here is o
for revert hunk and O
for revert commit. when you hit ?
in that mode there's not option for v
or V
on the version i'm looking at it is spacemacs though so perhaps v
and V
are overridden to keep visual mode working. I think the true answer is use ?
:) –
Firsthand Go to the hunk you want to undo and hit C-u C-c C-a
.
Emacs tells me that's undefined. –
Kolk
Maybe it's bound to another key in your config. The command is
diff-apply-hunk
(bound to C-c C-a
by default in diff-mode
). –
Immunity © 2022 - 2024 — McMap. All rights reserved.
E
and revert stuff withv
– Yordan