3

How do I force "my changes" when merging in git? Someone put all bin directories in git and now I have a terrible merge conflict :(

Now it says the following:

When you have resolved this problem run "git rebase --continue". If you would prefer to skip this patch, instead run "git rebase --skip". To restore the original branch and stop rebasing run "git rebase --abort".

I do NOT want to merge, i just want to delete all those files using my changes.

EDIT: Most of the files was successfully merged, either through automatic merge or because there was no conflict. However quite a few still exist like the following one.

warning: Cannot merge binary files: src/reports/obj/Debug/TempPE/GroupMailDS.Designer.cs.dll (HEAD vs. added gitignore)

mhenrixon
  • 6,179
  • 4
  • 40
  • 64
  • Perhaps you need to provide more detail on the conflicts, but can't you just do `git rm` on the files that you don't want; fixup any remaining real conflicts and `git rebase --continue`? – CB Bailey Jun 23 '10 at 08:49

3 Answers3

8

I'm not 100% confident about this, but I think this is a good case for this:

git merge otherbranch -s recursive -X ours

That command attempts to merge the topic branch into your checked out branch using the recursive strategy. The -X ours option is a subset of the recursive strategy that automatically resolves conflicts by making the assumption that your currently checked out branch is authoritative.

brycemcd
  • 4,343
  • 3
  • 26
  • 29
  • 2
    I have to try this because if that works that's greatness beyond the power of the darkside for anyone responsible of jedi/master! – mhenrixon Jun 24 '10 at 05:56
  • Wow! That's exactly what I was looking for. Talk about ludicrous speed! :) I believe it's a perfect situation to use this. All I wanted was to overwrite the other branch with my changes in case of conflicts even if it wasn't exactly what I asked for :) – mhenrixon Jun 24 '10 at 13:05
1

You can:

  • git rm the obj directory (which contains all those binary files and shouldn't have been committed in the first place)
  • add a .gitignore directive to make sure any future obj directory won't appear in the git status (and won't be added)
  • git push that new tree, helping to propagate the fact that 'obj' directory should disappear from other Git repos as well (hence triggering no merge at all).

If you can have the consent of all the other participants, you could:

But since it involves replacing published history by a new one, it should be done only if the other users agree.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
0

I guess you can just replace their binaries with yours (since no merge is really possible) or just git rm the unwanted binaries. After you have done, just git rebase --continue

ken
  • 13,869
  • 6
  • 42
  • 36