3

How does one ediff a current file--ie working tree--against an arbitrary version in some previous commit?

In this case, I'm interested in pulling in some, but not all, changes from a commit in another feature branch that was rejected.

1 Answer 1

2

I can't think of a one-step way to do this. The best I can come up with is

  • Type dr (magit-diff), and set the range to the commit

    If point is on the commit, you can copy it with C-w before calling dr.

  • In the diff buffer, go to the file you want and hit e (magit-ediff-dwim)

Though you might consider doing away with the ediff step. You can hit v to reverse a hunk at point in the working tree.

3
  • The twist is that the commit is in another branch; can you reverse from a commit not in the current one?
    – E Bro
    May 12, 2017 at 14:26
  • Did you try? When you enter a commit for a range, the diff shows the changes between that commit and the working tree (with the working tree changes treated as new).
    – Kyle Meyer
    May 12, 2017 at 18:13
  • Notably, you can now use C-x l from the magit-diff transient state to enable the -R option that reverses old and new, so that you get the diff in the order you want if you're pulling in changes selectively. Aug 30 at 14:53

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.