Move running merge of git to beyond compare
Asked Answered
O

2

14

I made certain changes in my local branch. I didn't commit. I just indexed all changes and moved them to stash. Now I did a

git pull

After git pull I did

git stash apply

Now there are some conflicts. In eclipse I am able to see the conflicts in normal git format

<<<< Updated Upstream
ksldjflsdk
sdlkfjdslk
sdlkfjsdlk
===========
sdlkfjdslk
dslkfjdslkfj
dsklfjsdlkjf
>>>>> Stashed Changes

Now there are some files with hell lot of conflicts. It is very difficult for me to look up and down and merge. Is there a way I can move current merge process to beyond compare.

I am on git version 1.8.3 and Beyond Compare 3.2.3

Ought answered 7/3, 2014 at 9:59 Comment(0)
K
24

I'm assuming that you're okay with launching Beyond Compare from the command line, and that you're on Windows. You can add the following lines to your global .gitconfig file:

[merge]
    tool = bc3
[diff]
    tool = bc3
[difftool "bc3"]
    cmd = "\"c:/program files (x86)/beyond compare 3/bcomp.exe\" \"$LOCAL\" \"$REMOTE\""
[mergetool "bc3"]
    cmd = "\"c:/program files (x86)/beyond compare 3/bcomp.exe\" \"$LOCAL\" \"$REMOTE\" \"$BASE\" \"$MERGED\""

Edit: Adding Mac commands straight from site:

git config --global diff.tool bc3
git config --global merge.tool bc3
git config --global mergetool.bc3.trustExitCode true

Then you can simply start conflict resolution with the following commands:

git mergetool # Starts Beyond Compare for all conflicted files, one at a time.
git mergetool -- <file> # Starts B.C. just for the specified file.
Kourtneykovac answered 7/3, 2014 at 10:6 Comment(3)
Yup it worked :) thanks a lot. Can you please quickly explain mein what is git LOCAL, BASE and REMOTE files in my scenario?Ought
BASE is the common ancestor of LOCAL and REMOTE. The files that LOCAL and REMOTE represent changes depending on the git operation. If you're merging, LOCAL represents the changes you're merging in from a branch, and REMOTE represents the file you're merging into. If you're rebasing, it's reversed, LOCAL represents the file being merged into, while REMOTE represents the file you're merging in. In the case of git stash apply, I'm not sure if it's considered to be like a merge or like a rebase.Kourtneykovac
I am not rebasing. I'll do simple merge and push.Ought
D
4

just an update based on the previous answer whose user seems to be inactive - please upvote the other post - for Beyond Compare 4 that would be (the only difference is the default directory with 4 instead of 3 in it and bcomp.exe turning into bcompare.exe) [Edit: global .gitconfig on Windows machines is usually in user's home directory, i.e. ~ in Git Bash or something like C:\Users\YourUserName]

[merge]
    tool = bcompare
[diff]
    tool = bcompare
[difftool "bcompare"]
    cmd = "\"c:/program files/beyond compare 4/bcompare.exe\" \"$LOCAL\" \"$REMOTE\""
[mergetool "bcompare"]
    cmd = "\"c:/program files/beyond compare 4/bcompare.exe\" \"$LOCAL\" \"$REMOTE\" \"$BASE\" \"$MERGED\""

Also git mergetool seems to generate backup files with the .orig ending - BC does not have to do something with it. Here there is a suggestion to just delete these files afterwards and leave the global git settings alone (syntax is for Git Bash):

find . -name *.orig -delete
Dilisio answered 17/2, 2021 at 9:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.