git - Create patch from two commits not in sequence not at the head -


i have repo single branch , 10 commits. want create patch commits affecting 2 of files in repo, example commits #3, 4, , 7, ie not head, not in sequence, , not labeled. i've kept scope of commits small don't affect unrelated files.

how should this?

i've looked @ lots of examples online including cherry-pick, squash, , checking out specific commit in temp branch, none of these appear close scenario, , head spinning @ possibilities.

make temporary branch

git checkout -b tmpb  #3^ 

cherry-pick commits #3, 4 , 7 branch

git cherry-pick #3 git cherry-pick #4 git cherry-pick #7 

squash them single commit

git rebase -i #3^ 

use git format-patch create patch

git format-patch master 

note, #3, #4 , #7 in commands should replaced respective sha1