Is there a way to merge single files in magit like you would do from this question or something equivalent. Namely:

$ git checkout source_branch -- <paths>...

2 Answers 2


As noted in many answers to the question you have linked to and even more so in comments on those answers, git checkout source_branch -- <paths>... does not perform a merge.

Never-the-less there are of course situations when you want to do that - just don't call it a "merge". It would be much more appropriate to talk about "putting a file in the worktree into its state as per a certain commit".

You can do that with M-x magit-file-checkout.

However you might actually be interested in only bringing in the changes (not final state) introduced by a certain commit to a certain file. To do that show the diff for that commit, then move to the file's heading in the diff and press a. That just applies just the changes that were introduced in that particular commit. You can also do that on the hunk and line level.


You can do this with M-x magit-file-checkout

This will allow you to pull in the changes from a specific file at a specific revision (you'll be prompted for those) into your working tree.

  • @Drew I added a bit more detail to the answer, hope that clarifies it Dec 21, 2017 at 19:16

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.