Let\'s say that I am 7 commits ahead of the origin/master repo. I would like to create a patch that includes in the patch specific files that were changed, not all the files
You can restrict the output of git diff
by listing paths at the end of the command (after a --
to avoid any potential clashes between path names and branch names). For example, you could do the following:
git diff origin/master HEAD -- app/models/region.rb doc/ > changes.patch
... to generate a patch that only shows the differences within a particular file and a particular directory.
You can include files in the patches with:
git format-patch <rev> <files...>
Example
git format-patch HEAD^^^ Makefile
Will give you three files 0001-[commit] ... 0003-[commit] only containing the Makefile.