我目前正在合并哪些提交? [英] Which commits am I currently merging?

查看:72
本文介绍了我目前正在合并哪些提交?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我执行git merge时,还没有创建新的提交(由于冲突或--no-commit选项),如何检查我要合并的分支?

When I executegit merge, no new commit are created yet (because of conflicts or --no-commit option), how to check which branch I am merging?

git status仅显示当前分支.

推荐答案

由于冲突而停止的git merge留下两个 1 文件,其中包含有关正在合并的内容的信息:

A git merge that has stopped due to conflicts leaves two1 files with information about what is being merged:

.git/MERGE_HEAD
.git/MERGE_MSG

(如果需要,例如将.git替换为git rev-parse --git-dir的输出,例如,如果您位于git目录中的子目录中).即使按名称合并分支,MERGE_HEAD的内容也是另一个SHA-1; 2 ,但是MERGE_MSG的内容包含分支名称(如果有).例如:

(replace .git with the output of git rev-parse --git-dir if needed, e.g., if you're in a sub-directory within the git directory). The contents of MERGE_HEAD is the other SHA-1, even if you're merging a branch by name;2 but the contents of MERGE_MSG contains the branch name if there is one. For instance:

$ git merge --no-commit origin/master
Automatic merge went well; stopped before committing as requested
$ cat .git/MERGE_HEAD
d1574b852963482d4b482992ad6343691082412f
$ cat .git/MERGE_MSG
Merge remote-tracking branch 'origin/master'

(由于没有冲突,我必须在这里使用--no-commit).

(I had to use --no-commit here since there was no conflict).

(如果两个文件中都没有分支名称,但是MERGE_HEAD文件的SHA-1与某些现有分支提示匹配,则该名称对于许多目的或大多数用途都是合适的分支名称.如果它与多个分支提示匹配,即,如果单个提交是当前多个分支名称的提示,那么任何一个都可能是合适的.)

(If there is no branch name in either file, but the MERGE_HEAD file's SHA-1 matches some existing branch tip, that would be a suitable branch name for many or most purposes. If it matches multiple branch tips—i.e., if a single commit is the tip of several current branch names—any of those could be suitable.)

1 还有第三个文件.git/MERGE_MODE,它告诉git首先您在合并的中间.但是,它通常是空的.

1There's a third file, .git/MERGE_MODE, which tells git that you're in the middle of a merge in the first place. It's often empty, though.

2 您可以通过原始SHA-1合并,也可以通过任何其他方式指定提交.不需要合并来自另一个分支.为此,在进行新的合并提交时,您也可以处于分离式HEAD"模式,因此不需要将合并合并到命名分支中.

2You can merge by raw SHA-1, or any other way to specify a commit. There's no requirement that the merge be from another branch. For that matter, you can be in "detached HEAD" mode when making a new merge commit as well, so there's no requirement that the merge be into a named branch.

这篇关于我目前正在合并哪些提交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆