如何获取合并分支从哪里分配的提交 [英] How to get commit where merged branch forked from
问题描述
o---1---o---o---o---o master
\ /
o---o---2 feature
是否可以在不使用reflog的情况下获得提交1?
使用git 2.4.2
Is it possible to get commit 1 without using reflog ? Using git 2.4.2
我试过了:
I tried:
git merge-base master feature
git merge-base feature master
returns: commit 2
git merge-base --fork-point master feature
git merge-base --fork-point feature master
returns nothing ( exit code 1 )
不重复:
- How to get a branch into a forked repo from the original repo in github
- git how to find commit hash where branch originated from
- How to get information where branch starts?
推荐答案
找到我的答案作为这个问题的一个子集:
(backporting实际上也是我的用例! )
https://stackoverflow.com/a/16718891/867294
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' -
我有点困惑,这不是默认的git的一部分。您至少会期望这将是 merge-base
的 - fork-point
选项的行为。如果有人知道更好/默认的选择。请把它放在评论或作为一个单独的答案!
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 !
这篇关于如何获取合并分支从哪里分配的提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!