GIT Tip: Saving current changes to a patch

If you use GIT for revision management, you might run into situations where you need to save your current changes without committing them.  While you can use the “git stash” command, the stash command applies to your entire working directory.  Sometimes it is useful to save changes from a particular sub-directory or project.

You can create a patch from your local changes:

git diff -p . > filename.patch

Note that the “.” can be any file specification (including wild-cards).

To apply the patch:

git apply filename.patch