我有一个带有以下提交的GIT主分支
Master:-
commit one
commit two
现在我创建了一个新的分支sprint1并添加了以下
Sprint1:
commit one
commit two
commit sprint1 one
主人和sprint1此时出现分歧
Master:
commit one
commit two
commit three
Sprint1:
commit one
commit two
commit sprint1 one
commit sprint1 two
commit sprint1 three
现在,当我将master合并到sprint1时,我得到以下内容,
Sprint1
commit one
commit two
commit sprint1 one
commit three
commit sprint1 two
commit sprint1 three
commit merged commit
但是当我将master合并到sprint1时,我期待以下内容: -
Sprint1
commit one
commit two
commit sprint1 one
commit sprint1 two
commit sprint1 three
commit three
commit merged commit
前者如何而不是后者。
答案 0 :(得分:1)
根据文档,提交以反向时间顺序显示。
要按照您期望的顺序获取提交,请尝试使用:
git log --oneline --topo-order
这可以避免显示多行历史记录中的提交混合。
有关详细信息,请参阅:https://www.kernel.org/pub/software/scm/git/docs/git-log.html#_commit_ordering
您还可以使用--graph
获得更好的输出,并单独显示分支。默认情况下,这意味着--topo-order
选项。
我有时喜欢通过别名的快速日志版本:
git --no-pager log --decorate=short --pretty=oneline --abbrev-commit --graph -n 10