我进行了三次合并:
git checkout master
git merge BranchA
>> Fast-forward merge
git merge BranchB
>> Three-way-merge (prompts for a merge commit message)我的问题有两个:
git log中),我将看到来自BranchA的提交,然后是BranchB的提交。编辑
为了更好地解释第二个问题,我做了一个测试:两个分支(A和B)从主分支开始。我对B作出了承诺,然后在A上,然后在B上,最后在A上,然后我将BranchA合并成了master。然后BranchB变成了主人。
但是当我在git log上讲到师父的时候,这就是为什么我会问第二个问题:
commit 730fdd4d328999c86fa4d3b6120ac856ecaccab1
Merge: 7eb581b cc1085a
Author: Arthur Conandoyle <Arthur.Conandoyle@live.com>
Date: Mon Feb 9 21:24:27 2015 +0100
Merge branch 'BranchB' into master_COPY
commit 7eb581b39a8402e1694cc4bf4eab4a3feb1143f8
Author: Arthur Conandoyle <Arthur.Conandoyle@live.com>
Date: Mon Feb 9 21:23:18 2015 +0100
BranchA) - This should be the (second) last change of the branch, and be the
most recent into the git log, even if I merge another branch into master,
AFTER the one where we are committing this.
commit cc1085a6aaa2ee4b26d3c3fbb93bee863d9e7c28
Author: Arthur Conandoyle <Arthur.Conandoyle@live.com>
Date: Mon Feb 9 21:20:29 2015 +0100
(BranchB) - Add settings to the last new features
commit 5f5b846a2f89886d01244ba77af941f554233b51
Author: Arthur Conandoyle <Arthur.Conandoyle@live.com>
Date: Mon Feb 9 21:18:54 2015 +0100
(BranchA) - Add some changes
commit 92a57a56b6b7c9694fbedda71b8070fc58683dde
Author: Arthur Conandoyle <Arthur.Conandoyle@live.com>
Date: Mon Feb 9 21:18:17 2015 +0100
(BranchB) - Some changes
commit 221765476e348833cf8da73b1bf5239f3d4240e8
Author: Arthur Conandoyle <Arthur.Conandoyle@live.com>
Date: Tue Feb 3 12:12:19 2015 +0100
Change (this is the last commit of the parent 'master' branch)(正如斯尔詹·格鲁伯所写),我应该首先(按时间顺序)从合并的BranchA和中得到所有的提交,然后按照合并的顺序从合并的BranchB中得到所有的提交。。。但是,有趣的是,git log如何以时间顺序显示它们,而提交却不显示为分组在分支中!
发布于 2015-02-09 18:27:24
branchB合并非常普通,需要一个普通的提交消息。默认情况下,如果不更改退出,则合并将完成。由于合并本身已经成功,现在停止它的唯一方法是提供一条糟糕的合并消息(空的合并消息会在没有钩子的情况下完成)、编辑:或者有一个编辑器可以像我刚刚了解到的vim的:cq那样出错。
当合并停止时,可以用
git merge --abort
# or
git reset --merge对您刚才错误提交的任何内容的回退是
git reset --hard @{1}在git中没有分支“所有权”的概念,引用提交的所有方法是对等的。
您可以更好地了解git日志向您展示的结构
git log --graph --decorate --oneline用--date-order、--topo-order和--all试一试。
发布于 2015-02-10 01:49:04
对于您的编辑,git log对其输出进行排序。即使在线性历史中,这也可能令人惊讶。有更改排序方法的标志,添加--graph将默认的排序更改为--topo-order。
另一个注意事项是,当git对分支执行快速转发时,不存在合并提交:
C---D <-- branch
/
A---B <-- mainline允许mainline通过简单图中的快速转发结果获取branch:
C---D <-- mainline, branch
/
A---B这是一条简单的直线,但强制合并提交(使用git merge --no-ff)会产生一个实际的双亲合并提交:
C---D <-- branch
/ \
A---B-------M <-- mainline这为提交排序过程提供了更有趣的选项(一旦推广到有更多提交)。
发布于 2015-02-09 18:27:01
您可以在完成和使用之后“中止”合并。
git reflog返回到以前的树状态。通常,合并不是按时间顺序排序,而是按分支提交顺序排序,然后再分别排序。这意味着您将看到您的合并提交,然后是所有源分支提交(按时间顺序),然后是您的主分支提交(按时间顺序)。
https://stackoverflow.com/questions/28416470
复制相似问题