When I do merge preview m p I see a log of other branch changes for each affected file. Changes marked like this:

@@ -20,6 + 22,7 @@
-    <change>
+    <change>

To merge only a particular file I can do from command line:

git checkout another_branch -- ./path/to/file

(btw, is there a way to do it in Magit?)

BUT, suppose, I want to merge only specific changes from the log, and not the entire file. Is there any way to do that in magit, or git cli? Ideally I'd love to check the changes that I want to merge manually.

1 Answer 1


To merge only a particular file I can [use git checkout] from command line:

This does not perform a merge. This does not only apply the changes from the other branch, it also discards changes that have been made on your branch since the other branch diverged.

I want to merge only specific changes from the log

Show the diff appropriate changes. For each change that you want to apply move to it and press a to apply it. This may fail if there is a conflict, in which case C-u a should work.

"Selective applying" works the same way as "selective staging" using s; you can act on a complete file, hunk, or even just parts of a hunk using the region.

For more information see sections of the manual titled Staging and Unstaging, Applying and Merging.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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