Frage

AFAIK, git diff shows all differences between commits, including those that would not result in a merge conflict.

Is there a way to list only those files in branch otherbranch that would have a conflict if I were to run git merge otherbranch? Is there a way to list the actual conflicts (in some diff-like format)?

War es hilfreich?

Lösung

Is there a way to list only those files in branch otherbranch that would have a conflict if I were to run git merge otherbranch?

When you run git merge or git rebase you can get back to the state you were before running git reset --merge (or git merge --abort since 1.7.4) or git rebase --abort.

At this point you can list files with git diff --name-status --diff-filter=U command

Is there a way to list the actual conflicts (in some diff-like format)?

There are many ways to have a 3-way merge view if you want a smart way to see and edit the merge conflicts, it depends on your favourite evironment setup.

In example with VIM you can bind this two commands in your gitconfig

edit-unmerged = \ "!f() { git ls-files --unmerged | cut -f2 | sort -u ; }; vim f"

add-unmerged = \ "!f() { git ls-files --unmerged | cut -f2 | sort -u ; }; git add f"

And handle 3-way merge with this method Fugitive.vim - resolving merge conflicts with vimdiff

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top