Chinaunix首页 | 论坛 | 博客
  • 博客访问: 138096
  • 博文数量: 18
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 186
  • 用 户 组: 普通用户
  • 注册时间: 2013-02-04 12:22
文章分类

全部博文(18)

文章存档

2013年(18)

我的朋友

分类: Android平台

2013-02-04 21:19:33

 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.patchmc3.patchd2c1.patch ,d2c2.patch

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

git format-patch –root dev1
结果为 mc2.patchmc3.patchd2c1.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的分支mergedev2分支

dev2分支下,git merge --commit dev1

10.找到dev2master分支上的commitID

git merge-base dev2 master
会显示dev2master两个分支的共同的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"
阅读(21659) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~