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
    Commented Sep 26, 2018 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
    Commented Sep 26, 2018 at 5:50
  • github.com/magit/magit/issues/3601 Commented Sep 26, 2018 at 14:19

1 Answer 1


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 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.