当前位置:   article > 正文

git 生成多个patch_git生成Patch和打Patch

git format-patch调用相邻两次comit但是patch很多

在程序员的日常开发与合作过程中,对于code的生成patch和打patch(应用patch)成为经常需要做的事情。

使用方法(直接给一些examples):

1.生成patch

1.1 git diff > xxx.patch

#只想 patch Test.java 文件

git diff Test.java > test.patch

# 把所有的修改文件打成 patch

git diff > test.patch

1.2.git format-patch

$ git format-patch HEAD^ #生成最近的1次commit的patch

$ git format-patch HEAD^^ #生成最近的2次commit的patch

$ git format-patch HEAD^^^ #生成最近的3次commit的patch

$ git format-patch HEAD^^^^ #生成最近的4次commit的patch

$ git format-patch ..  #生成两个commit间的修改的patch(包含两个commit. 和都是具体的commit号)

$ git format-patch -1     #生成单个commit的patch

$ git format-patch      #生成某commit以来的修改patch(不包含该commit)

$ git format-patch --root #生成从根到r1提交的所有patch

2,应用patch

git apply是另外一种打patch的命令,其与git am的区别是,git apply并不会将commit message等打上去,打完patch后需要重新git add和git commit,而gi

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/652572
推荐阅读
相关标签
  

闽ICP备14008679号