With command line git you can use git format-patch [commit_hash] [file] to generate a patch for a single file. Is there a way to generate a patch in magit for only a single file? I tried marking the files like I would when staging multiple files, but it still created a patch for the whole commit.

  • No, magit-format-patch doesn't support that, and this isn't an option that you can simply define with magit-define-popup-option. I think it's a feature worth proposing on magit's issue tracker. – Kyle Meyer Sep 26 at 0:22
  • It is a pretty simple start-process -- at the very least, someone here could create an interactive function that would gather the commit-sha and filename and plug it into the command-line passed to start-process. – lawlist Sep 26 at 5:50
up vote 2 down vote accepted

Magit supports this now. In the patch popup press = F and then type the name of the file (with completion). You can also input multiple files, separated by comas.

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.