svn 出现冲突时可以使用 meld . 命令合并。 而git的冲突合并详见内容

1、可以在任意目录使用 git mergetool --tool-help    查看 git 所支持的merge tools。

2、可以使用如下配置去设置merge tool 和 diff tool:

git config --global --add merge.tool kdiff3
git config --global --add mergetool.kdiff3.path "C:/Program Files/KDiff3/kdiff3.exe"
git config --global --add mergetool.kdiff3.trustExitCode false

git config --global --add diff.guitool kdiff3
git config --global --add difftool.kdiff3.path "C:/Program Files/KDiff3/kdiff3.exe"
git config --global --add difftool.kdiff3.trustExitCode false

# git config --global --add diff.tool kdiff3 #一般不将默认的diff tool设为gui的tool

git difftoolgit mergetool 命令的说明:

-g
--[no-]gui

When git-difftool is invoked with the -g or --gui option the default diff tool will be read from the configured diff.guitool variable instead of diff.tool. The --no-gui option can be used to override this setting.

简单的说就是有-g选项则使用 diff.guitool 设置的tool来作为diff tool。这个参数只对 git difftool 命令有效。

--[no-]trust-exit-code

git-difftool invokes a diff tool individually on each file. Errors reported by the diff tool are ignored by default. Use --trust-exit-code to make git-difftool exit when an invoked diff tool returns a non-zero exit code.

git-difftool will forward the exit code of the invoked tool when --trust-exit-code is used.

也就是说git-difftool对每个文件分别调用一个 diff tool,每个diff tool的运行错误默认都是被忽略的。 使用 --trust-exit-code 可以在某个 diff tool 运行后返回非0时使 git-difftool 退出。

如果使用了 --trust-exit-code,则git-difftool会将返回码往下传递。

3、当冲突发生时,你可以简单的使用 git mergetool 来解决冲突。具体演示如下:

a、你修改了某些文件,且没有提交到本地库,这时你向pull服务器的版本,你大概是这样做的:

$ git fetch origin
$ git pull origin master

From ssh://gitosis@example.com:22/projectname
 * branch            master     -> FETCH_HEAD
Updating a030c3a..ee25213
error: Entry 'filename.c' not uptodate. Cannot merge.

b、上面的错误提示你有一个文件未能更新,因为它未提交新的更改,因此不能merge。因此你一般会这样做来试图解决这个冲突:

$ git add filename.c
$ git commit -m "made some wild and crazy changes"
$ git pull origin master

From ssh://gitosis@example.com:22/projectname
 * branch            master     -> FETCH_HEAD
Auto-merging filename.c
CONFLICT (content): Merge conflict in filename.c
Automatic merge failed; fix conflicts and then commit the result.

c、当你提交更改之后再pull,则git会自动对更改的文件进行merge,但上面提示merge发生冲突,接下来你应该这样来查看有哪些地方发生了冲突:

$ git mergetool

但是这一步还有例外,也许你并不想合并冲突,因为你有足够的信心直接采用文件的某个版本,这时你可以这样:

$ git checkout --ours filename.c
$ git checkout --theirs filename.c
$ git add filename.c
$ git commit -m "using theirs"

d、最后结束merge:

$ git pull origin master
$ git push master From
ssh://gitosis@example.com:22/projectname * branch master -> FETCH_HEAD Already up-to-date.

冲突合并到此结束。

对于svn的合并,若出现错误,则其目录里将会有一些merge文件,这时候你可以直接再冲突的目录使用如下命令来合并冲突:

$ meld .
原文地址:https://www.cnblogs.com/welhzh/p/5735380.html