Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to revert a change from older commit in `magit`?

Tags:

git

emacs

magit

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).

like image 813
lukstafi Avatar asked Nov 05 '13 21:11

lukstafi


People also ask

What is git revert reset?

For this reason, git revert should be used to undo changes on a public branch, and git reset should be reserved for undoing changes on a private branch. You can also think of git revert as a tool for undoing committed changes, while git reset HEAD is for undoing uncommitted changes.


1 Answers

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

like image 61
Tom Willis Avatar answered Oct 14 '22 14:10

Tom Willis