2

when merging with git there are a lot of conflicts, I just want to Keep target or take source - is there a way to do this from UI or git command line so I can do them for multiple/all files? thank you. Visual studio used to allow us to do with TFVC repos.

enter image description here

Edit: note - that I don't want to use -Xtheirs or -Xours on git command line, because I dont necessarily want all the files in the merge to be auto merged with ours or theirs - I would want to choose which files (or first merge some of the files differently so what's left would either be auto merged as ours or theirs). is there a command or way to do this in UI to do this AFTER the merge command and not part of the merge command so I can first choose different merge for other files.

dan
  • 801
  • 15
  • 41

2 Answers2

2

using -Xours or -Xtheirs parameter in merge command you solve this issue

git merge -Xours merging_branch_name

OR

git merge -Xtheirs merging_branch_name

for details follow this link

jobayersozib
  • 401
  • 2
  • 7
  • thanks for reply but not really what i want. I dont necessarily want all the files in the merge to be auto merged with ours or theirs - I would want to choose which files (or first merge some of the files differently so what's left would either be auto merged as ours or theirs). is there a command to do this AFTER the merge command and not part of the merge command so I can first choose different merge for other files? thanks – dan Sep 16 '21 at 20:32
2

You can use git checkout [--ours|--theirs] on a list of files or directories :

git checkout --ours -- file1
git checkout --theirs -- file2
git add file1 file2

# you can specify any number of patterns :
git checkout --ours -- file1 file2 dir3/ that/dir/too/
LeGEC
  • 46,477
  • 5
  • 57
  • 104
  • see also https://stackoverflow.com/questions/24916186/how-to-do-git-checkout-theirs-for-multiple-files-or-all-unmerged-files – LeGEC Oct 13 '21 at 21:55