Fandom

Git Wiki

Patches

30pages on
this wiki
Add New Page
Talk0 Share

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>

e.g.

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

branch Edit

In any case always create a branch!

git checkout -b <local_branch>

or

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>

tag Edit

git tag <tag-name>

push Edit

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>

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.