- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我需要解决git中的冲突,但是作为一个新手,不知道什么是最有效的方法。
这是我的情况:
我在 master
中,需要提交并推送我的所有更改。
$ git pull:
error: Your local changes to 'foo.cpp' would be overwritten by merge. Aborting. Please, commit your changes or stash them before you can merge.
有几个冲突的文件。当然,我在网上搜索了一下:
How to resolve merge conflicts in Git?
不幸的是,这两种解决方案都效果不佳。我可能会使用 stash(获取 diff 并使其干净)并进行手动解析,但我想使用 git mergetool
或 SourceTree。
这是我试过的:
$ git config merge.conflictstyle diff3
$ git mergetool
merge tool candidates: tortoisemerge emerge vimdiff
No files need merging
$ git mergetool -t vimdiff
No files need merging
$ git mergetool -t vimdiff foo
foo.cpp: file does not need merging
$ git diff foo.cpp
diff --git a/foo.cpp b/foo.cpp
index xxxxxx yyyyy
--- a/foo.cpp
+++ b/foo.cpp
@@ .....
..... <omitted>
$
我不确定哪里出了问题。 git mergetool
无法正常工作。它说不需要 merge 。但是,它显示差异并且 git pull
报告冲突。
Q1) 如何使用 mergetool
进行交互式冲突解决或 merge ?
Q2)是否可以使用SourceTree来解决冲突?我试过了,但也不直观。
谢谢!
最佳答案
您看到的错误:
error: Your local changes to 'foo.cpp' would be overwritten by merge. Aborting. Please, commit your changes or stash them before you can merge.
是因为您有未提交的更改
(它在 SourceTree 显示的最顶部显示)。如果您有未提交的更改,任何 merge 尝试都将失败。您有三个选择:
git reset --hard
)git stash
)git add ...; git commit ...
)完成后,您将被允许 merge 。如果您选择上面的选项#3,那么可能会出现冲突;选项#1 或#2 不会有冲突。 [注意:对于选项 #2,您将稍后执行 git stash pop
,然后可能会出现冲突。]
对于您的 Q1:执行 git config merge.tool diff3
(或 vimdiff,或其他)。 merge 可能会造成混淆(它通常是 3 向 merge ,因此该工具显示三个版本和一个组合版本)。
对于您的问题 2:SourceTree 不包含它自己的 merge 工具;你需要依赖另一个(我使用 p4merge 和 SourceTree)。使用这些配置选项:
difftool.sourcetree.cmd=/Applications/p4merge.app/Contents/MacOS/p4merge "$LOCAL" "$REMOTE"
difftool.sourcetree.path=
mergetool.sourcetree.cmd=/Applications/p4merge.app/Contents/MacOS/p4merge "$BASE" "$LOCAL" "$REMOTE" "$MERGED"
mergetool.sourcetree.trustexitcode=true
关于git - 解决 git 冲突 : git mergetool doesn't work,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15798063/
git mergetool 命令性能似乎相当慢,尤其是与 hg merge 相比。这是一个记录在案的问题吗?有什么方法可以加快速度吗? 在运行命令时,我们花了很多时间等待每个文件差异的显示。 最佳答案
git-mergetool 是否有一个标志,其行为类似于 --follow from git-log? --follow Continue listing the history
在机器 A 上,git mergetool 按预期运行 Beyond Compare 3。在机器 B 上,BC3 启动但未在命令行上传递任何参数,因此显示介绍屏幕而不是实际 merge 。 我将配置从
merge 后,我想使用 git mergetool 来解决问题,但无论我指定什么工具,它都失败了: git mergetool
我安装了 meld,运行 git mergetool , merge 左右文件到中心文件,保存,关闭窗口。我记得其他时候 mergetool 询问 merge 是否成功,但这次没有(我会回答"is")
我已经执行了 git mergetool 来尝试解决一些 merge 冲突。 它会打开 3 个文本窗口(在我的 SSH 终端内),每个窗口都有不同版本的代码。 我要的代码在右边的窗口中。 我如何告诉
当运行 git mergetool 时,我想让 git 根据文件扩展名选择使用的 merge 工具。我怎样才能做到这一点? 此处提出了类似的问题:Git: configure patterns for
我想在 libgit2sharp 中使用“git mergetool”的等效项。有没有样本可以做到这一点?还是我必须深入研究并尝试在 libgit2sharp 中实现它? “git mergetool
作为 git pull 命令的结果,我使用 git mergetool 命令对一些冲突文件进行了一些更改,但我想将其还原到我使用 mergetool 进行更改之前的状态。 基本上就是git警告有冲突并
我有冲突,所以我输入: git mergetool 然后我收到一条消息说: Hit return to start merge resolution tool 通常当我这样做时,它会打开 kdiff3
当我使用 Kdiff3(以及我尝试过的其他 merge 工具)执行 merge 冲突解决时,我注意到在解决时创建了一个 *.orig 文件。有没有办法让它不创建那个额外的文件? 最佳答案 来自 git
我如何强制始终显示 mergetool GUI 并禁用任何自动解析? 有时当在 merge 过程中发生冲突并且我使用 mergetool 时,它会在我点击Enter 问题“点击返回开始 merge 解
我发现 git mergetool 是一个方便的实用工具,可以直观地 merge 差异,但我的处理方式似乎很奇怪。本质上,当报告冲突时,我的流程如下所示: 执行 git mergetool 在出现提示
我在 git 中使用 DiffMerge 进行三向 merge 。我刚刚完成了一项强制 merge 工作,但意识到我遗漏了一些东西,想重新 merge 并使用相同的 3 向 GUI 功能。当我尝试时:
我正在使用 CLI mergetool vimdiff 而不是逐行输入 :diffg RE 为每个更改选择 REMOTE 版本,有没有办法我可以只将整个文件的远程版本作为目标 merge 吗? 最佳答
如描述中所述。我什至不希望在自动解决 merge 冲突时提示解决 merge 冲突。 我的场景是,我在一个分支上的文本文件中添加一行包含固定文本字符串的行,在同一分支上做一些其他提交,然后在另一个分支
在 Mercurial 中,可以为外部 diff 和 merge 工具定义一个模式(这样它们只会被与指定模式匹配的文件调用): [diff-patterns] **.ext = difftool [m
我配置我的 git 来解决与 Sublimerge 的 merge 冲突。为此,我跑了: git config --global merge.tool sublimerge git config --
是否可以在 Git 中设置一个自定义工具来 merge 具有特定扩展名的文件? 谢谢指点! 更新 除了定义自定义 difftool 并按照@jarodeells 的建议手动调用它之外,我想不出任何更好
git config --global mergetool.bc3 "\"c:/program files (x86)/beyond compare 3/bcomp.exe\"\"$LOCAL\"\"
我是一名优秀的程序员,十分优秀!