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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM