【问题标题】:Git merge master into branch commit orderingGit 将 master 合并到分支提交排序中
【发布时间】:2016-10-19 19:10:10
【问题描述】:

我有一个带有以下提交的 GIT 主分支

Master:-
      commit one
      commit two

现在我创建了一个新的分支 sprint1 并添加了以下内容

Sprint1:
      commit one
      commit two
      commit sprint1 one

此时master和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

如何是前者而不是后者。

【问题讨论】:

  • 你如何查看提交顺序? github?终端?其他 git 工具?
  • 命令行终端..
  • git log --oneline..哪一个是正确的顺序,“提交三”在“sprint 1 two”和“sprint 2 three”之前完成
  • 我使用git log --oneline --graph 将分支提交分开并按顺序排列
  • 这个命令真的很有帮助..它符合预期..让我重新创建并查看它..非常感谢..

标签: git github merge


【解决方案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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-30
    • 2018-04-03
    • 2013-01-14
    • 2016-09-20
    • 2017-04-26
    相关资源
    最近更新 更多