Patching with Git

Creating a Patch

Patch for Working Copy (Not Committed)

git diff > patch.diff

Patch from one commit to another

git diff <from-commit-hash> <to-commit-hash> > patch.diff

Patching a Project Generated from git diff

Applying a Patch: git apply patch.diff

Solution for Whitespace Errors

git apply --ignore-space-change --ignore-whitespace patch.diff

Make sure that you removed whitespaces from both patch file and from the files you are going to patch.


  1. Whitespace errors
  2. Applying git patch