Alexander Bird
Alexander Bird

Reputation: 40669

what are "automerged" files in git, and how do you list them all?

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

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?


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.

Upvotes: 2

Views: 285

Answers (1)

Alexander Bird
Alexander Bird

Reputation: 40669

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.

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
$ 

Upvotes: 1

Related Questions