Is there any command to list only auto merged files in git after taking pull. Auto merging is not forcing us to watch code. Some time I needed to check explicitly to automerged files.
Git enlists changed files generally in three types in mix up. New files comes or old file deleted, auto merged and conflict.if git internally identifies automered files so I just thought there would be any command to list only auto merged files.by the way I want to get this list before the merge commit.
For clarity in this answer, let's start with a few definitions and notes:
--no-commit
or gotten a merge conflict. If the latter, you have not resolved these conflicts already.HEAD
commit is the tip of this branch now. So the phrase "the HEAD
commit" below means "the tip of the branch before doing the merge".Based on your comment-reply, I believe you want to find files that have any change from the HEAD
commit, i.e., those that have picked up any changes from the inbound commit, whether or not git has merged those without finding a conflict.
If this is correct, the answer is quite simple:
git diff --cached --name-only
will list them. (This is a bit of a surprise since git diff --cached
without --name-only
does not show the unmerged files.)
Should you want only files git has (or thinks it has) successfully merged:
git status --porcelain | awk '/^M / { print $2 }'
will list those. (Leave out the awk
, and optionally use -s
or --short
instead of --porcelain
, to see the output from git status
. In this case we look for files whose state is "merged, ready to commit". Files with merge conflicts will be in M
state.)
You may also want to compare files to their merge-base versions. This is not too difficult except in the (somewhat rare) case of multiple merge-bases. I will leave these details out of this answer, though.