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

This entry was posted
on Wednesday, September 7th, 2011 at 9:54 am and is filed under Tips.
You can follow any responses to this entry through the RSS 2.0 feed.
Both comments and pings are currently closed.