赞
踩
在程序员的日常开发与合作过程中,对于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
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。