git apply 打补丁
一:生成patch 和打patch?
有這樣的 目錄層次 x/xx/xxx/xxx/test.c
我的當前位置是在 x/? 下 ,執行? ?git diff> test.patch
在test.patch補丁文件里的路徑信息是這樣的:
?- - - a/xx/xxx/xxx ??
+++b/xx/xxx/xxx ??
如果 應用 test.patch 的時候的 位置 是在 x/ 下,
執行:
patch -p1 < test.patch
--------------------------------------
git diff> test.patch,這是產生patch的方式。
注意,使用gitdiff產生的patch都應該在執行 patch 命令時,? 指定-p1,當 位置是 【在哪里制作的patch,就在哪里 執行】
?
二:
$git apply 0006-Philips-VSO-library-Report-only-the-actual-data-to-a.patch
error: patch failed: sensors-see/sensors-hal/sensors/philips_rr.cpp:81
error: sensors-see/sensors-hal/sensors/philips_rr.cpp: patch does not apply
error: patch failed: sensors-see/sensors-hal/sensors/philips_spo2.cpp:81
error: sensors-see/sensors-hal/sensors/philips_spo2.cpp: patch does not apply
?
$ git am --reject 0006-Philips-VSO-library-Report-only-the-actual-data-to-a.patch
Applying: Philips VSO library: Report only the actual data to application i.e. data[5].
Checking patch sensors-see/sensors-hal/sensors/philips_rr.cpp...
warning: sensors-see/sensors-hal/sensors/philips_rr.cpp has type 100755, expected 100644
Checking patch sensors-see/sensors-hal/sensors/philips_spo2.cpp...
Applied patch sensors-see/sensors-hal/sensors/philips_rr.cpp cleanly.
Applied patch sensors-see/sensors-hal/sensors/philips_spo2.cpp cleanly.
?
git ?apply --reject ?xxxx.patch?
自動合入 patch 中不沖突的代碼改動,同時保留沖突的部分。這些存在沖突的改動內容會被單獨存儲到目標源文件的相應目錄下,以后綴為 .rej 的文件進行保存。
比如對 ./test/someDeviceDriver.c 文件中的某些行合入代碼改動失敗,則會將這些發生沖突的行數及內容都保存在 ./test/someDeviceDriver.c.rej 文件中。我們可以在執行 git am 命令的目錄下執行?find ?-name ?*.rej?命令以查看所有存在沖突的源文件位置。
$ git am --reject 0007-Adjust-the-touch-threshold-as-low-as-possible-to-mak.patch
Applying: Adjust the touch threshold as low as possible to make the off-body distance shorter
Checking patch sensors-see/registry/config/A4100/sdm429w_pah_8131_0.pah_8136.param_cal.json...
error: while searching for:
? ? ? ? "8": {
? ? ? ? ? ? "type": "int",
? ? ? ? ? ? "ver": "0",
? ? ? ? ? ? "data": "124328280"
? ? ? ? },
? ? ? ? "9": {
? ? ? ? ? ? "type": "int",
? ? ? ? ? ? "ver": "0",
? ? ? ? ? ? "data": "40961131"
? ? ? ? },
? ? ? ? "10": {
? ? ? ? ? ? "type": "int",
error: patch failed: sensors-see/registry/config/A4100/sdm429w_pah_8131_0.pah_8136.param_cal.json:48
error: while searching for:
? ? ? ? ? ? "data": "1117"
? ? ? ? }
? ? }
}
error: patch failed: sensors-see/registry/config/A4100/sdm429w_pah_8131_0.pah_8136.param_cal.json:81
Applying patch sensors-see/registry/config/A4100/sdm429w_pah_8131_0.pah_8136.param_cal.json with 2 rejects...
Rejected hunk #1.
Rejected hunk #2.
Patch failed at 0001 Adjust the touch threshold as low as possible to make the off-body distance shorter
Use 'git am --show-current-patch' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
?
總結
以上是生活随笔為你收集整理的git apply 打补丁的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: db2 load 快速_使用 DB2 的
- 下一篇: make[1]: *** 没有规则可制作