Git: Merging very large master branch with a feature branch

246 views Asked by At

Now, I'm very aware of the possibility that I'm just doing this totally wrong, so let me describe my problem.

I have a feature branch of a very active master branch. The project is extremely large. I've changed ~30 files in my branch, and it's not done yet, so I need to make sure I keep up with master. So, I do:

git merge --no-commit -s recursive -X theirs upstream/master

I get a giant mess. The files I didn't touch are often merged in really stupid ways, and the files I did touch are of course merged badly. The ones I did touch I understand that I have to fix myself.

I've tried other arguments to git merge as well, but it's not doing what I want.

How can I merge the master into my branch, and somehow say that it should just overwrite everything but the stuff I have touched?

Right now, the process I have to follow is this:

  • Do the merge
  • Make sure my unaltered copy of the master branch is up to the same revision as the merge I just did.
  • Run WinMerge on the two source directories and see all of the files it broke with stupid merges.
  • Every file I didn't touch, copy from the unaltered side to the merge side. (I'm aware that I could do this with git checkout, but when you're dealing with hundreds of files that it broke, I prefer a gui.)
  • Go back and manually merge the files I did touch, making sure that my changes survived. Sometimes they're fine, sometimes they're overwritten. It seems random.

So, what am I doing wrong here?

1

There are 1 answers

1
Animesh Sharma On

Perform the following steps:

git merge master

Conflicts will appear.

For files changed by you:

git checkout --ours file_name_modified_by_you

For files not modified by you:

git checkout --theirs file_name_not_modified_by_you