Skip to content

Latest commit

 

History

History
58 lines (38 loc) · 1.56 KB

File metadata and controls

58 lines (38 loc) · 1.56 KB

README

Quick walkthrough of how to use git patching.

REF: 85_patches/README.md

TODO:

  • Be careful with binary files
  • Patching single files or a selection of files

Contents

Creating a patch from diff

Creating patch files.

# create a patch for the difference
git format-patch HEAD~1     

# calculate single patch for branch (without -1 each commit is a patch)
git format-patch -1 $(git merge-base --fork-point master)..mybranch

Creating a patch with unstaged changes

Create a patch of unstaged files.

git config --global alias.make-patch '!bash -c "cd ${GIT_PREFIX};git add .;git commit -m ''uncommited''; git format-patch HEAD~1; git reset HEAD~1"'

git make-patch

git diff HEAD > file_name.patch

Applying patches

# applying a patch
patch -p1 -i patches/image-js+0.33.1.patch    

# git apply only works for files in index.
git apply --ignore-whitespace patches/image-js+0.33.1.patch  

Resources

  • Send A Patch To Someone Using git format-patch here
  • Example of generating patches for node_modules here