views:

370

answers:

2

So I have my master branch, along with branch 'bob'.

I've made many changes in both and now I want merge master into bob to keep him updated. The only thing is, if there is a conflict I want it to automatically resolve to bob.

I've been recommended the following:

git checkout bob
git merge master -s ours

This does not work because I don't even get the changes from master that don't conflict.

please help!

+1  A: 

First, you need to merge all changes from master to bob:

  • all modification from master must be added to bob if there is no conflict
  • any conflict must be solved by keeping content of bob branch.

The question "How do I tell git to always select my local version for conflicted merges on a specific file?" explains how to do that, with a merge driver.

Once the merge has been done, a simple:

 git checkout master
 git rebase bob

allows for the HEAD of master to fast-forward to the one of bob. Master will go on from there from the content of bob.

VonC
I know: I did already mention the merge driver in my previous answer to your first question, but it does fit your current need.
VonC
Using a merge driver seems like a lot of work.. I would think there would be some simple command for something like this.Where can I find a good toturial on merge drivers?
tybro0103
A: 

I see the gap with the ours merge strategy. If integrating your own merge driver is too much, and if you like Emacs, consider using ediff as your "merge tool". You can tell it to "prefer" your contributions in conflicts. That in addition to having it focus only on conflicting changes allows you to review the merge result before committing, just to make sure that taking only your contributions still result in a coherent file.

Unfortunately, ediff has yet to be integrated as a supported merge tool. This thread on the git mailing list from June 2007 describes some of the integration problems. Here's another.

Git does ship with built-in support for emerge, another Emacs merging mode, but I far prefer ediff.

seh