Git:按合并顺序提交

问题描述 投票:1回答:1

我编写了一个python脚本,遍历我的master分支中的最后10个提交。主分支受限于提交,只能合并到。

考虑以下情况。

分支1在上午10点完成提交,提交1和2分支2在上午11点完成提交,提交3和4。

我将分支1之前的分支2合并到master。

现在,当我在迭代时打印提交时,仍然会打印4和3,然后是2和1。

我需要先按照最新提交的顺序迭代到master。 IE浏览器。我需要它为2,1,4和3.这可能吗?

python git gitpython
1个回答
0
投票

sort optionsgit log是:

  • --date-order
  • --author-date-order
  • --topo-order
  • --reverse

在你的情况下,--topo-order将完成这项工作:

> git log --topo-order --no-merges --format="%ad -- %s"
2019-03-12 18:05:02 -- c2 (topic1)
2019-03-12 18:04:59 -- c1 (topic1)
2019-03-12 18:05:22 -- c4 (topic2)
2019-03-12 18:05:19 -- c3 (topic2)
2019-03-12 18:04:47 -- commit on master
© www.soinside.com 2019 - 2024. All rights reserved.