1, generate patch
(1)git diff (commit id1) (commit id2) --binary >diff01.diff
First check the git log:
commit 0f8f0738fd6c2ff1826c831f56e04495063bda98
Date: Tue Jul 28 14:07:07 2020 +0800
Change-Id: I9e859ab9e2bc1ad053011e2eaf11a5b471072db6
commit bdc605552aa171fe791eee28a4ae5130547fb5ae
Date: Tue Jul 28 13:39:36 2020 +0800
Change-Id: Id3884e60b06ce17b111488353612fd529a77e92b
I want to generate a patch for commit 0f8f0738fd6c2ff1826c831f56e04495063bda98
git diff bdc605552aa171fe791eee28a4ae5130547fb5ae 0f8f0738fd6c2ff1826c831f56e04495063bda98 --binary >diff01.diff
(2)git format-patch -M master
The git log is as follows:
commit 0f8f0738fd6c2ff1826c831f56e04495063bda98
Date: Tue Jul 28 14:07:07 2020 +0800
Change-Id: I9e859ab9e2bc1ad053011e2eaf11a5b471072db6
commit bdc605552aa171fe791eee28a4ae5130547fb5ae
Date: Tue Jul 28 13:39:36 2020 +0800
Change-Id: Id3884e60b06ce17b111488353612fd529a77e92b
I want to generate a patch for commit 0f8f0738fd6c2ff1826c831f56e04495063bda98
git format-patch 0f8f0738fd6c2ff1826c831f56e04495063bda98 -1
I want to generate a patch for commit 0f8f0738fd6c2ff1826c831f56e04495063bda98 and bdc605552aa171fe791eee28a4ae5130547fb5ae
git format-patch 0f8f0738fd6c2ff1826c831f56e04495063bda98 -2
2,Apply patches
(1)git apply 0001-songtingting-bug59036-modify-perferred-network.patch
(2) Check the content of the patching failure git apply --check 0001-songtingting-bug59036-modify-perferred-network.patch
error: Patching failed: packages/SettingsProvider/res/values/defaults.xml:243
error: packages/ SettingsProvider/res/values/defaults.xml: Patch is not applied
(3) There is also a more thorough method:
git apply --reject 0001-songtingting-bug59036-modify-perferred-network.patch