10

Possible Duplicate:
Git - how to force merge conflict and manual merge on selected file

We're trying to do a merge between two branches: stable code, and new features.

The merge functionality is not working for us: it sometimes shows conflicts, but often just overwrites files without telling us of any conflict, probably with what it thinks is the right version.

Is it possible to block this overwrite so that it shows us all the conflicting lines? We tried using git diff to get an idea of how extensive it was but there are a couple thousand lines because we had pretty extensive debugging on our stable branch...So we'd really need to get the merge functionality working if at all possible.

So we're in a bit of a messy situation, will greatly appreciate all help.

Community
  • 1
  • 1
Eric Hiland
  • 101
  • 1
  • 4

2 Answers2

2

As I do not know how to reproduce your problem, I need to do some guesswork.

In my experience, confusion surrounding git merge can be usually reduced by doing a git pull --rebase before doing the merge. This pulls in the latest changes from remote, and merges your changes over them. However, do not do this if you intend to merge your changes over an earlier commit. In any case, note down the latest commit ID before doing the pull, so that you can revert to it if there's a problem.

Now coming to the merge itself, you could try using git merge --no-ff --no-commit to prevent the merge from being committed. I do not know if this would give you the full conflict report that you would like to see, but it allow you to examine the merge result (like a simulation mode). If you do not like the result, you could revert the merge using git reset --hard.

Masked Man
  • 1
  • 7
  • 40
  • 80
2

What you can do, is run the merge as:

git merge --no-commit --no-ff your-branch

This will not create a merge commit or fast forward the master, but will simply put the merged files in your working directory. You can examine the changes. Once you are satisfied you can do a git commit or revert by git reset --hard

ShadyKiller
  • 700
  • 8
  • 16
  • Thanks ShadyKiller, and ap. for your solutions. They give us a lead as to how to solve it, but it seems that still even using this merge method, some of the code gets simply ignored without the changes appearing. We're trying to figure out why. We'll post back here if we can get further. Thanks again. – Eric Hiland Dec 20 '12 at 21:59
  • hello @EricHiland we are also facing the same issue. do you have any update on this ? – sktguha Apr 04 '17 at 13:52