Git create and apply patch files

To create a git patch file from the uncommitted changes in the current working directory use command:


git diff > filename.patch

In case some part of the work you’re doing are new files that are untracked and won’t be in your git diff output. So, one way to do a patch is to stage everything for a new commit (git add each file, or just git add .) but don’t do the commit, and then run:


git diff --cached > filename.patch

You can use the ‘binary’ option if you want to add binary files to the patch (e.g. mp3 files):


git diff --cached --binary > filename.patch

You can later apply the patch by running:


git apply filename.patch

Read more options at https://stackoverflow.com/questions/5159185/create-a-git-patch-from-the-uncommitted-changes-in-the-current-working-directory.