git 生成patch和打patch

有这样的 目录层次 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

posted on 2015-07-15 19:42  Cynthia&Sky  阅读(16277)  评论(0编辑  收藏  举报

导航