有這樣的 目錄層次 x/xx/xxx/xxx/ttt.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的方式。
注意,使用git diff產生的patch都應該在執行patch 命令時,指定-p1,當 位置是 【在哪里制作的patch,就在哪里 執行】
或者直接使用git apply test.patch 打補丁,執行 這個 命令的位置 也是<在哪里制作的patch,就在哪里執行此命令>。
生成patch
git diff > file.patch
打patch
patch -p1 < file.patch
git apply file.patch
參考:
git apply 補丁 (最簡單明了,很清晰)
http://blog.csdn.net/wh_19910525/article/details/8190828
如何打patch p0 p1區別
http://blog.csdn.net/misiter/article/details/7395608