Create a patch including specific files in git

You can create a patch file by restricting 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

Above commands generate a patch that shows only the differences for a particular file: region.rb and a particular directory : doc when compared to origin/master

Then you can apply the patch using

patch -p1 < changes.patch

The -p1 tells patch to strip the a/ and b/ in the paths in the patch

Leave a Comment

404 Not Found

Not Found

The requested URL was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.