我有一些客户分支机构和一个开发分支机构。客户分支不时地被合并回开发分支。对于Update,开发分支被合并到获得Update的customer分支中。
现在我想知道,最后一次更新合并是什么,或者开发和客户分支之间的最后一次合并是什么。
例如,如果我有以下历史记录:
o---o---o---o---o---o c1
/ \
o---1---o---2---o---o---3---o dev
\ / \ / /
o---o---o---o---o---o c2在本例中,我希望找到从dev到c2的最后一次合并,即2。
我从git merge-base中找到了this answer,但这给了我3,因为这是两个分支中的最后一个提交。
我还试着查看提交,它在dev中,而不是在c2中,但是我也从c1那里得到了很多旧的提交。
发布于 2021-01-11 09:09:59
Commit 2是最近的提交,这两者都是:
dev
c2
祖先的first-parent祖先
您可以通过将git命令与grep和head相结合来识别它:
# two lines and a temp file :
# 1. list the hashes of 'first-parent' commits from branch 'dev' :
git rev-list --first-parent dev > /tmp/dev.log.txt
# 2. in the parents of branch 'c2', look for the first line which matches a
# first-parent of 'dev'
git rev-list c2 | grep -f /tmp/dev.log.txt | head -1
# one liner ('<(...)' works in bash and zsh) :
git rev-list c2 | grep -f <(git rev-list --first-parent dev) | head -1https://stackoverflow.com/questions/65663358
复制相似问题