git 生成patch和打patch

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

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值