Git command to only create files without conflict markers?

Bazaar has a handy command bzr resolve

that will recursively mark conflicting files as resolved, but only if their conflict markers have been removed. Is there an equivalent command or script for git?

My repository contains minified Javascript (I know it's not ideal for keeping track of compiled files) that often conflicts after a merge, even if the unminified source is merged cleanly. It is easily fixed through re-evaluation and resolution and does not require any manual conflict resolution. My team is migrating from Bazaar to Git, and we've come to rely on bzr resolve

clever handling of files with conflict markers: it's safe to blindly run it in the project root after minification. In the future, I would like to automate this process and fully compile the code from the repository, but at the moment I am looking for a way to mirror our current process to Git.

I know it git diff --check

will report the remaining conflict markers, but it still takes extra effort to run it and check its output before running it git add

. And running a pre-commit hook that looks for conflict markers is not ideal unless the hook can also disable the corrupting files and mark them as unresolved (which I haven't found how to do). Are there any better options?


source to share

3 answers

You must try git mergetool

. It reruns the merge, but it does so interactively, with your merge tool of choice, and auto-merges the file when you're done.



When you get conflicts in git during a merge or redirect, files without conflicts will be automatically delivered, these are only files with conflicts that you need to worry about, i.e. resolve conflicts and execute them manually. There is no need to resolve files without conflict markers, they are already resolved.



When resolving this type of conflict, you can use one of the following commands:

git checkout --theirs <filename>


(or ours

instead theirs

if you prefer local changes) to select the correct version, or even do it automatically for the whole merge with:

git merge -s recursive -Xtheirs


(or accordingly -Xours


This is the answer I found in the question: git merge recursive theirs, how does it work?



All Articles