git - 查找两次提交的第一个普通 child

标签 git merge branch git-branch

           :
           A
T         / \
i        B   C
m        :   :
e        D   E
          \ /
|          F
V          :
git merge-base B E允许找到两个提交的共同祖先A所在的位置。有没有办法找到提交F,两个分支再次 merge ?

最佳答案

哎呀。没有足够仔细地阅读。

提交中的唯一信息是其父代(或多个父代)的ID。您无法从父提交中找到 child (这是DAG存储库的直接组成部分)。

进一步了解-看起来git log的--ancestry-path选项可以做到这一点。例如给出:

* 85d26ab When compiling vim, also compile & install gvim
*   3146e5d Merge remote-tracking branch 'origin/devel' into deve
|\
| * 28d08e5 rebasing-merge: specify all commits explicitly
* | 006d11d Help 'file' find its magic file
|/
* e68531d (tag: Git-1.7.6-preview20110720) Update submodules

我们可以使用获得这两个提交的所有子级
git log --oneline --ancestry-path B..E

如果您随后将其反转并选择第一个-即F。
git rev-list --reverse --ancestry-path 28d08e5..006d11d | head -1

在我的情况下,返回3146e5d。

关于git - 查找两次提交的第一个普通 child ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10922262/

相关文章:

linux - Windows Git 服务器和 Linux Git 客户端

r - 连接两个具有部分公共(public)和不相等列的数据框

svn - git-svn 不提交给分支机构,只提交给主干

git - 如何更改 Gitlab 中 merge 的默认目标分支

git - 获取在 git 中上次运行时 merge 的文件列表

Eclipse/Subclipse : Switch from branch to trunk with modified sources?

git - 如何截断或减少 GitHub 上的 git repo

git - 如何配置 'git diff' 以使用 emacs diff

Git merge-base 在构建服务器克隆的 repo 上没有产生任何结果

Git merge 到历史上的旧点