Guest User

Untitled

a guest
Nov 15th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. ## Generate a patch from un-commited files:
  2. `git diff > file.patch`
  3.  
  4. 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:
  5.  
  6. `git diff --cached > file.patch`
  7.  
  8. Add the 'binary' option if you want to add binary files to the patch (e.g. mp3 files):
  9.  
  10. `git diff --cached --binary > file.patch`
  11.  
  12. ## Generate a patch between two commits
  13. `git diff commitid1 commitid2 > file.patch`
  14.  
  15. ## Generate a patch between the HEAD and a specific commits
  16. `git diff commitid1 > file.patch`
  17.  
  18. ## Generating a patch from excluded files
  19. `diff -u path/to/file path/to/new/file > file.patch`
  20.  
  21. ## Generate a patch from git stash
  22. `git stash show -p > file.patch`
  23.  
  24. ## Apply the patch:
  25. `git apply mypatch.patch`
Add Comment
Please, Sign In to add comment