Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you get a Git merge to ignore conflicts in selected files? [duplicate]

I am merging a feature branch into the master branch and I want to overwrite some of the files in the master branch. The files I want to overwrite generally contain text configurations and some binary data encoded as text so they are bound to be problematic and I don't care about those anyway. They are intended to replace those in the master.

Auto-merging frmShopSupportIncidents.lfm
CONFLICT (content): Merge conflict in frmShopSupportIncidents.lfm
Auto-merging frmNewShop.lfm
CONFLICT (content): Merge conflict in frmNewShop.lfm
Auto-merging frmCliCustsBrowser.lfm
CONFLICT (content): Merge conflict in frmCliCustsBrowser.lfm
Auto-merging custManager.lpi
Auto-merging clientShopFrame01.lfm
CONFLICT (content): Merge conflict in clientShopFrame01.lfm
Automatic merge failed; fix conflicts and then commit the result.

How do I get the conflicts to be ignored and overwritten any way?

like image 342
vfclists Avatar asked Nov 22 '25 08:11

vfclists


2 Answers

You can use:

git checkout --theirs .

To accept all the upstream changes.

Or if you know that only for some files you would like to use the upstream version apply the checkout only for these files, for the rest of them you can resolve the conflicts manually. Eg.

git checkout --theirs frmNewShop.lfm frmCliCustsBrowser.lfm  
like image 189
dan Avatar answered Nov 23 '25 23:11

dan


I would say that configuration files do not belong being committed in GIT to start with.

However, to keep "your" changes you can follow: https://medium.com/@porteneuve/how-to-make-git-preserve-specific-files-while-merging-18c92343826b#.r3hadlpt5

like image 26
tkarls Avatar answered Nov 23 '25 22:11

tkarls