Home > other >  How to list the files that caused a merge conflict in Git, even after you've resolved some of t
How to list the files that caused a merge conflict in Git, even after you've resolved some of t

Time:12-10

I'm resolving a large merge conflict in a Git repository. Partway through the process, I realize that I may have resolved some conflicting files incorrectly. However, I don't remember which files had contained merge conflicts. I don't want to throw out all of my work. So how can I list the conflicted files while I'm resolving a merge conflict?

Note that I haven't committed the merge yet.

This post does not resolve my question, as it only lists files that are currently conflicted (i.e. they have the <<<<<<<<<<< markers). Stated differently, I'd like to know which files caused the conflict in the first place.

CodePudding user response:

Here git diff with its diff-filter might be helpful

Try using

git diff --diff-filter=[(A|C|D|M|R|T|U|X|B)...[*]]

A: Select only files that are Added

C: Copied

D: Deleted,

M: Modified

R: Renamed,

T: have their type (i.e. regular file, symlink, submodule, ...) changed

U: are Unmerged (U) X: are Unknow B: have had their pairing Broken .

Any combination of the filter characters (including none) can be used.

CodePudding user response:

If you need more details you always can clone the project to a separate directory and start merging of the branches one more time. Or, if you are merging your local branches, would be an option to duplicate the project folder on the hard drive, then abort the merging process and start a new one. Eventually, you would have a possibility to inspect your changes more thoroughly.

  • Related