How to get commit where merged branch forked from

后端 未结 3 1313
轮回少年
轮回少年 2020-12-19 05:11
o---1---o---o---o---o     master
     \\         /
      o---o---2           feature

Is it possible to get commit 1 without using reflog ? Using gi

3条回答
  •  长情又很酷
    2020-12-19 05:33

    Found my answer as a subset from this question: ( backporting was in fact also my usecase ! ) https://stackoverflow.com/a/16718891/867294

    [alias]
        oldest-ancestor = !bash -c 'diff -u <(git rev-list --first-parent "${1:-master}") <(git rev-list --first-parent "${2:-HEAD}") | sed -ne \"s/^ //p\" | head -1' -
    

    I am somewhat baffled that this is not part of git as default. You would at least expect that this would be the behavior of the --fork-point option for merge-base. If anyone knows a better/default alternative. Please put it in the comments or as a separate answer !

提交回复
热议问题