4

I've recently purchased beyond compare pro to merge code shared with git (of which I have a very limited understanding). I now have two branches, a master and a feature. I recently pulled the master from remote so that now the master is a few commits ahead of the common ancestor between master and feature.

Since my branch feature has mostly deletions I want to merge master into feature and not the reverse (does this make sense?). So I basically did

git checkout master
git pull origin master
git push origin master

So at this point my feature is a few commits behind and a few commits ahead of master. To merge the commits of master into feature I did:

git checkout feature
git merge master
git mergetool

Now I'm prompted with a series of messages like

Deleted merge conflict for 'ED/build/make/rules.mk':
  {local}: deleted
  {remote}: modified file
Use (m)odified or (d)eleted file, or (a)bort? m

Normal merge conflict for 'ED/src/driver/ed_model.F90':
  {local}: modified file
  {remote}: modified file
merge of ED/src/driver/ed_model.F90 failed
Continue merging other unresolved paths [y/n]? y

All other files give a failed merge error without even opening the beyondcompare mergetool to do the merge.

  • The first prompt says (m)odified or (d)eleted, does this mean that I have to choose which file to select between local and remote as a result of the merge?
  • The second prompt tells me that the merge failed, why is this happening?

EDIT

The relevant part of my .gitconfig is

[diff]
    tool = bc3
[difftool]
        prompt = false
[difftool "bc3"]
    trustExitCode = true
[core]
    fileMode = false
    symlink = false
    ignorecase = true
[merge]
    tool = bc3
[mergetool "bc3"]
    trustExitCode = true
[alias]
    difftool = difftool --dir-dif --no-symlinks
Manfredo
  • 1,760
  • 4
  • 25
  • 53
  • 1
    Please show us the configuration of your mergetool. – Lasse V. Karlsen Jul 10 '17 at 15:46
  • I guess the error has partly to do with BC having (/being viven by git) the wrong paths for the 3 files comparison since the address are all the same with appended a LOCAL/REMOTE/BASE keyword – Manfredo Jul 10 '17 at 16:50
  • Try specifying the path to beyond compare 3. – Lasse V. Karlsen Jul 10 '17 at 16:51
  • What would that change since BC is opened correctly? Also this is how it's commonly set. – Manfredo Jul 10 '17 at 19:08
  • So you're saying that Beyond Compare does in fact open up? I'm sorry, I missed that. – Lasse V. Karlsen Jul 10 '17 at 19:09
  • Yes sorry I've been unclear. So it opened for the first file (the .gitignore) with the proper comparison panes; then for the rest of the files it opened but with empty panes saying no files were found. However if I do git status I see all the files that have changed and need to be merged as for the .gitignore. – Manfredo Jul 10 '17 at 19:36

2 Answers2

4

The first prompt says (m)odified or (d)eleted, does this mean that I have to choose which file to select between local and remote as a result of the merge?

Yes. Probably you want to choose the (d)eleted state, assuming you wish those files to remain deleted in your feature branch and don't care how they may have been changed since you originally deleted them.

Typically your master is intended to be in sync with the remote at all times. Local changes such as deleting files are properly done in a feature branch as you are doing, so that's good. If your changes are purely local, never intended to become a permanent part of the main project, then they stay in the feature branch forever, and you occasionally merge from master to feature whenever you pull fresh updates from the remote, exactly as you are doing. The only time you want to merge back from feature into master and then push is to change something for everyone using the project.

The second prompt tells me that the merge failed, why is this happening?

  • Did you resolve every conflict called out in Beyond Compare (marked with "!" in the margin)?
  • Does your middle column look the way you want for every difference?
  • Did you save the merged file?

If the answer to any of these is "no" then you return to git with merge markers still in the file, which means "I didn't finish". In other words, that merge "failed", meaning it did not get completely finished successfully.

I wouldn't worry about the file addresses looking wrong. When git attempts to resolve a merge, it copies the three different versions (remote, local, merged) into three temporary files. When you're done editing and merging, it copies the 'merged' one back into your local file.

All other files give a failed merge error without even opening the beyondcompare mergetool to do the merge.

This seems strange. Typically git will continue one by one. Sorry I can't be of more help here.

Sean Gugler
  • 779
  • 8
  • 18
1

If you want to see the unresolved conflicts in Beyond Compare you can run git mergetool which will open conflicts with your default merge tool. You have to first setup git to use Beyond Compare if you haven't already.

Instructions for configuring found here.

Confuzing
  • 217
  • 1
  • 11
  • The errors are showing after having run the mergetool. And I set it up according to the instructions. It's not a matter of setup because I have already run the mergetool in a different occasion. – Manfredo Jul 10 '17 at 15:43
  • So you have resolved merge conflicts with Beyond Compare in the past, or is this the first time it is not auto-resolving? – Confuzing Jul 10 '17 at 15:45
  • So here's the situation: Initially I tried to merge the feature branch into the master. I thought this made more sense per se. However I later noticed that all the stuff I had removed in my feature was included in the merged files because it was there on the master. I then decided to merge the master into the feature. In the first occasion, when merging the feature into the master, the BC mergetool woud pop up with all 3 windows and the merged. Now it's doing this only for the .gitignore and skipping all the other files with the error message I reported... – Manfredo Jul 10 '17 at 15:59