It's already mentioned here ( modify local repository and create a patch ) how to create a patch.
how to create a patch Edit
#hack, commit, hack, commit,... git format-patch -M -C -s --keep-subject -o 2009_07_16-0001-to_amou <version_to_patch_against>
git format-patch -M -C -s --keep-subject -o 2009_07_16-0001-to_amou origin git tag -f 2009_07_16-0001-to_amou
how to apply a patch Edit
In any case always create a branch!
git checkout -b <local_branch>
git -b <local_branch> git checkout <local_branch>
check if it's a valid patch Edit
git apply --reject --whitespace=fix --stat my-patches/rber/koukou/0001-permission-changes.patch git apply --reject --whitespace=fix --check my-patches/rber/koukou/0001-permission-changes.patch
if it's a valid patch Edit
git am --signoff < my-patches/rber/koukou/0001-permission-changes.patch
Note that this also does the commit, git status, git commit will not show any change To see the last commit (done by am) do:
git diff HEAD^
merge to main branch Edit
git checkout master git merge <local_branch>
git tag <tag-name>
git push origin master git push --tags
this will destroy the author and signed-off info - don't use it!
git apply --reject --whitespace=fix my-patches/rber/koukou/0001-permission-changes.patch
how to apply a series of patches from a mailbox Edit
git am <folder_with_series_of_patches>
how to apply a series of patches without a mailbox Edit
how to apply a diff/patch style patch Edit
If you get a non-git patch you might have fun applyin it;) I got from a chipset manufacturer a patch, which looks like which was not generated with git, but perversely enough their instructions tell to use git to apply the patch.
git apply --binary <patch>
As expected this did not really work out of the box, since they somehow expected a .gitconfig file, I did not have.
Qt_to_Lamda.patch:1049: space before tab in indent. char *p; Qt_to_Lamda.patch:1052: space before tab in indent. sz=(sizeof(RenderArenaDebugHeader)+127) & (~127); Checking patch .gitignore... error: .gitignore: No such file or directory ...
The obvious solution was:
git apply -v --binary -p1 --exclude .gitignore <patch>