Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## Generate a patch from un-commited files:
- `git diff > file.patch`
- But sometimes it happens that part of the stuff 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 (but don't do the commit), and then:
- `git diff --cached > file.patch`
- Add the 'binary' option if you want to add binary files to the patch (e.g. mp3 files):
- `git diff --cached --binary > file.patch`
- ## Generate a patch between two commits
- `git diff commitid1 commitid2 > file.patch`
- ## Generate a patch between the HEAD and a specific commits
- `git diff commitid1 > file.patch`
- ## Generating a patch from excluded files
- `diff -u path/to/file path/to/new/file > file.patch`
- ## Generate a patch from git stash
- `git stash show -p > file.patch`
- ## Apply the patch:
- `git apply mypatch.patch`
Add Comment
Please, Sign In to add comment