您好,欢迎访问代理记账网站
移动应用 微信公众号 联系我们

咨询热线 -

电话 15988168888

联系客服
  • 价格透明
  • 信息保密
  • 进度掌控
  • 售后无忧

git format-patch命令介绍

git format-patch的使用

1.在dev1分支上,打出所有dev1分支在master分支基础上的patch

git format-patch master

结果为d1c1.patch ,d1c2.patch

2.在dev1分支上,打出所有dev1分支的所有patch

git format-patch –root dev1

结果为mc1.patch,d1c1.patch ,d1c2.patch

3.在dev2分支上,打出所有dev2分支在master分支基础上的patch

git format-patch master

结果为d2c1.patch ,d2c2.patch

4.在dev2分支上,打出所有dev2分支的所有patch

git format-patch –root dev2

结果为mc1.patch,mc2.patch,mc3.patch,d2c1.patch ,d2c2.patch

5.在dev2分支上,打出所有相对于dev1分支的所有patch

git format-patch –root dev1

结果为 mc2.patch,mc3.patch,d2c1.patch ,d2c2.patch

6.比较两个分支

git diff dev1 dev2

7.比较两个分支中单个文件的区别

git diff dev1 dev2 main.c

8.将所有的commit信息保存在文件中

git log > commit.txt

git log | grep “commit” -A3 >commit.txt 保存commit开始的3行

-An after , -Bn before, -Cn(前后n行)

9.将dev1的分支merge到dev2分支

在dev2分支下,git merge --commit dev1

10.找到dev2在master分支上的commitID

git merge-base dev2 master

会显示dev2和master两个分支的共同的commitID


撤消历史提交
1
git revert commit_ID
例子:提交历史如下
ss@ss:/work/test$ git log
commit 70869ac8cc36c05267aad41954f89d068d2d8142
Author: ss
Date:   Thu Mar 21 20:12:58 2013 +0800

    new a

commit 226e1a70d720f47d21d3664688d9dc34665ba84f
Author: ss
Date:   Thu Mar 21 20:05:36 2013 +0800

    commit c

commit ff45af7db705904bc49fc09679b2c384ce778d1a
Author: ss
Date:   Thu Mar 21 20:05:23 2013 +0800

    commit b

commit 76e846f8ee0106840767d5522c7d33d7f752527b     
Author: ss
Date:   Thu Mar 21 20:05:08 2013 +0800

    commit a

commit 8e7979f6617ae9fc6ae3666002bf17482bd10e28
Author: ss
Date:   Wed Feb 20 20:06:09 2013 +0800

    Iitial

如果我想撤消
commit 226e1a70d720f47d21d3664688d9dc34665ba84f
Author: ss
Date:   Thu Mar 21 20:05:36 2013 +0800

    commit c
这笔提交;则使用命令:git revert 226e1a70d720f47d21d3664688d9dc34665ba84f
效果如下:
commit 40f83cb1fa45702ec31bcdd4426580551edfae8e
Author: ss .com>
Date:   Thu Mar 21 20:13:07 2013 +0800

    Revert "commit c"
    
    This reverts commit 226e1a70d720f47d21d3664688d9dc34665ba84f.
commit 70869ac8cc36c05267aad41954f89d068d2d8142
Author: ss
Date:   Thu Mar 21 20:12:58 2013 +0800

    new a

commit 226e1a70d720f47d21d3664688d9dc34665ba84f
Author: ss
Date:   Thu Mar 21 20:05:36 2013 +0800

    commit c

commit ff45af7db705904bc49fc09679b2c384ce778d1a
Author: ss
Date:   Thu Mar 21 20:05:23 2013 +0800

    commit b

这样在这一比提交的东西将会被撤销
2
若想撤消
commit 70869ac8cc36c05267aad41954f89d068d2d8142
Author: ss
Date:   Thu Mar 21 20:12:58 2013 +0800

    new a

commit 226e1a70d720f47d21d3664688d9dc34665ba84f
Author: ss
Date:   Thu Mar 21 20:05:36 2013 +0800

    commit c

commit ff45af7db705904bc49fc09679b2c384ce778d1a
Author: ss
Date:   Thu Mar 21 20:05:23 2013 +0800

    commit b

这三笔提交
可以用命令
git reset --hard 76e846f8ee0106840767d5522c7d33d7f752527b  这笔ID为commi a
git reset --soft 70869ac8cc36c05267aad41954f89d068d2d8142
git commit -m "cccc"

 


分享:

低价透明

统一报价,无隐形消费

金牌服务

一对一专属顾问7*24小时金牌服务

信息保密

个人信息安全有保障

售后无忧

服务出问题客服经理全程跟进