什么是git中的“automerged”文件,你如何列出它们?

时间:2022-12-27 22:50:29

I ran a git merge master --no-commit in a branch and the only output given was this:

我在一个分支中运行了一个git merge master --no-commit,给出的唯一输出是:

Auto-merging path/to/file
Automatic Merge went well; stopped before committing as requested

However, git diff HEAD --name-status shows that there are about 15 files that where modified (prefixed with 'M') and 3 files which were added (prefixed with 'A'). Aren't all modified files from a merge considered "Automerged"? So what is so special about this particular file that it would printed as "automerged" but not the rest?

但是,git diff HEAD --name-status显示大约有15个文件经过修改(以“M”为前缀)和3个已添加的文件(前缀为“A”)。并非合并中的所有修改文件都被视为“Automerged”?那么这个特殊文件有什么特别之处呢?它会打印成“automerged”而不是其他文件?


more information (this is before I have committed the merge):

更多信息(这是在我提交合并之前):

$ git log --oneline --graph --decorate  --all
* ae3f058 (master) synced code from another source.
| * 3bd4147 (HEAD, branchA) blah blah blah
| * f6513f6 random message
| * fcbe65e more messages from commit history
| * 6bc99e2 I like green eggs and ham
|/
| * 1824723 (branchB) This is some other, unrelated branch.
|/
* 5a98fac some stuff right before branching
* 40b05f1 initial commit.

1 个解决方案

#1


1  

The reason that file, and that file alone, was listed is because that is the only file which was changed in BOTH branches. For all other files, one or the other was simply chosen ("fast-forwarded") and never truly merged in an algorithmic sense.

列出文件和单独文件的原因是因为这是在BOTH分支中更改的唯一文件。对于所有其他文件,简单地选择了一个或另一个(“快进”)并且从未在算法意义上真正合并。

Here's how I figured that out (this was done before committing the merge):

这是我如何计算出来的(这是在提交合并之前完成的):

$ git merge-base HEAD MERGE_HEAD
5a12345
$ git diff HEAD 5a12345 --name-only > files_changed_in_HEAD
$ git diff MERGE_HEAD 5a12345 --name-only > files_changed_in_MERGE_HEAD
$ comm -12 files_changed_in_HEAD files_changed_in_MERGE_HEAD > files_changed_in_both
$ cat files_changed_in_both
path/to/file
$ 

#1


1  

The reason that file, and that file alone, was listed is because that is the only file which was changed in BOTH branches. For all other files, one or the other was simply chosen ("fast-forwarded") and never truly merged in an algorithmic sense.

列出文件和单独文件的原因是因为这是在BOTH分支中更改的唯一文件。对于所有其他文件,简单地选择了一个或另一个(“快进”)并且从未在算法意义上真正合并。

Here's how I figured that out (this was done before committing the merge):

这是我如何计算出来的(这是在提交合并之前完成的):

$ git merge-base HEAD MERGE_HEAD
5a12345
$ git diff HEAD 5a12345 --name-only > files_changed_in_HEAD
$ git diff MERGE_HEAD 5a12345 --name-only > files_changed_in_MERGE_HEAD
$ comm -12 files_changed_in_HEAD files_changed_in_MERGE_HEAD > files_changed_in_both
$ cat files_changed_in_both
path/to/file
$