在git中显示未提交合并的父母 [英] Show parents of uncommitted merge in git
问题描述
我怎样才能在git中看到未提交的合并的父母?我可以通过执行 git log -1
来查看其中的一位父母,但我如何查看其他父母?
这是在Mercurial中很容易做到:
$ $ p $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $变更集:2:b65656dbfff6
tag:tip
父母:0:1806d848df54
用户:Stephen Rasku
日期:星期二11月27日10:14:31 2012 -0800
汇总:c
changeset: 1:9aaa22944f41
用户:Stephen Rasku
日期:星期二11月27日10:14:01 2012 -0800
汇总:b
git中是否有任何等价物?我知道你可以在Git中看到一个承诺合并的父母。这是专门查看未提交合并的父母。
未提交合并的来源存储在的.git / MERGE_HEAD
。如果您正在执行章鱼合并,则此文件中将有多个提交ID,换行符分隔。合并的目标当然是 HEAD
。
如果你想要一个详细的输出,类似于这个例子你从Mercurial提供的,你可以将它提供给 git log
,正如你注意到的那样。如果你想命名这个脚本 git-parents
,那么可以使用shell脚本来处理这个脚本。 >,并将其放在你的路径中,你可以简单地运行 git parents
来获得与你所描述的类似的体验:
#!/ bin / sh
git --no-pager log -1
WORKDIR =`git rev-parse --show- toplevel`
if [-f$ {WORKDIR} / .git / MERGE_HEAD];然后
作为`cat$ {WORKDIR} /。git / MERGE_HEAD| xargs`; do
git --no-pager log -1 $ a
done
fi
How can I see the parents of an uncommitted merge in git? I can see one parent by doing git log -1
but how do I see the other parent?
This is easy to do in Mercurial:
$ hg parents
changeset: 2:b65656dbfff6
tag: tip
parent: 0:1806d848df54
user: Stephen Rasku
date: Tue Nov 27 10:14:31 2012 -0800
summary: c
changeset: 1:9aaa22944f41
user: Stephen Rasku
date: Tue Nov 27 10:14:01 2012 -0800
summary: b
Is there anything equivalent in git? I know you can see the parents of a committed merge in git. This is specifically to see the parents of an uncommitted merge.
The sources of an uncommitted merge are stored in .git/MERGE_HEAD
. If you are performing an octopus merge, you will have multiple commit IDs in this file, newline delimited. The target of the merge, of course, HEAD
.
If you want a detailed output, similar to the example you provided from Mercurial, you can feed that into git log
, as you noted. It may be easiest to write a shell script to handle this.
If you were to name this script git-parents
, and place it in your path, you could simply run git parents
to get a similar experience to what you described:
#!/bin/sh
git --no-pager log -1
WORKDIR=`git rev-parse --show-toplevel`
if [ -f "${WORKDIR}/.git/MERGE_HEAD" ]; then
for a in `cat "${WORKDIR}/.git/MERGE_HEAD" | xargs` ; do
git --no-pager log -1 $a
done
fi
这篇关于在git中显示未提交合并的父母的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!