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>...
up vote 11 down vote accepted

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 – Anntoin Wilkinson Dec 21 '17 at 19:16

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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