Visual Studio 2013 不提供在 Git pull 上进行合并
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27458236/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Visual Studio 2013 does not offer to do merge on Git pull
提问by trailmax
I'm working with Visual Studio 2013 Update 4 and git (hosted on Visual Studio Online). I have 2 local commits and 2 commits in remote branch. There are NO local changes to commit:
我正在使用 Visual Studio 2013 Update 4 和 git(托管在 Visual Studio Online 上)。我在远程分支中有 2 个本地提交和 2 个提交。没有要提交的本地更改:
When I try to do Pull (or Fetch) in Visual Studio, I get error:
当我尝试在 Visual Studio 中执行 Pull(或 Fetch)时,出现错误:
An error occurred. Detailed message: 1 conflict prevents checkout
发生错误。详细信息:1 冲突阻止结帐
Yes, there is a conflict, I should do merge. And according to this pageI should be offered a link to resolve conflict.But I don't see that in VS.
是的,有冲突,我应该合并。根据这个页面,我应该得到一个解决冲突的链接。但我在 VS 中没有看到这一点。
I can do merge outside of VS, but that's not the point. At the same time, my workmate running the same set up can do the merge with no issues. What is wrong with my VS?
我可以在 VS 之外进行合并,但这不是重点。同时,我运行相同设置的同事可以毫无问题地进行合并。我的 VS 有什么问题?
p.s. I have msysgit installed that might have messed with configurations. According to this postmy global .gitconfig
looks like:
ps 我安装了可能弄乱了配置的 msysgit。根据这篇文章,我的全局.gitconfig
看起来像:
[user]
mail = [email protected]
name = trailmax
email = [email protected]
[core]
excludesfile = C:\Users\trailmax\Documents\gitignore_global.txt
autocrlf = true
editor = \"C:/Program Files (x86)/GitExtensions/GitExtensions.exe\" fileeditor
[diff]
tool = vsdiffmerge
[difftool "vsdiffmerge"]
cmd = \"C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\vsdiffmerge.exe\" \"$LOCAL\" \"$REMOTE\" //t
keepbackup = false
trustexistcode = true
[merge]
tool = vsdiffmerge
[mergetool]
prompt = true
[mergetool "vsdiffmerge"]
cmd = \"C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\vsdiffmerge.exe\" \"$REMOTE\" \"$LOCAL\" \"$BASE\" \"$MERGED\" //m
keepbackup = false
trustexistcode = true
[credential]
回答by Leniel Maccaferri
In my case I could not see the Resolve the conflicts
option because I had local changesnot committed yet and I was trying to sync with the remote changes. As soon as I committed my local changesand then tried a sync again, Resolve the conflicts
link appeared.
在我的情况下,我看不到该Resolve the conflicts
选项,因为我尚未提交本地更改,并且我正在尝试与远程更改同步。一旦我提交了本地更改,然后再次尝试同步,Resolve the conflicts
链接就会出现。
So the point here is: commityour changes first and then try to sync. A mergewill start and Visual Studio will allow you to go through each of the conflicts.
所以这里的重点是:首先提交您的更改,然后尝试同步。一个合并将启动Visual Studio将让你去通过每个的冲突。
回答by Karlo Medallo
I have encountered the same issue where "An error occurred. Detailed message: 1 conflict prevents checkout" is shown where there's no option to resolve the conflict as shown in Leinel's answer.
我遇到了同样的问题,“发生错误。详细消息:1 冲突阻止结帐”显示在没有解决冲突的选项的地方,如 Leinel 的回答所示。
The reason was due to an untracked file that is the same file that is to be pulled. I just deleted the untracked file and retried the pull.
原因是由于未跟踪的文件与要拉取的文件相同。我刚刚删除了未跟踪的文件并重试了拉取。
回答by azuneca
I had the same issue. It turns out that I had an untracked file that needed to be included. Therefore, check in Changes tab for untracked files.
我遇到过同样的问题。事实证明,我有一个需要包含在内的未跟踪文件。因此,请检查未跟踪文件的更改选项卡。
回答by Jess
I did not have any "Changes" (untracked or otherwise) listed on either branch, so the other answers did not work for me.
我在任何一个分支上都没有列出任何“更改”(未跟踪或以其他方式),因此其他答案对我不起作用。
I decided to go command line:
我决定去命令行:
- Click Syncon both branches.
- Switch to the branch you want to "merge into" (master in my case).
- In Team Explorer under Manage Branches, do Action -> Open Command Line.
- In the command line type
git merge BRANCH_NAME
. (my work branch / merge "from") - Now the Resolve the conflictsbutton is available.
- 单击Sync两个分支。
- 切换到要“合并到”的分支(在我的情况下是 master)。
- 在Manage Branches下的 Team Explorer 中,执行Action -> Open Command Line。
- 在命令行中键入
git merge BRANCH_NAME
. (我的工作分支/合并“来自”) - 现在解决冲突按钮可用。
回答by VonC
If the conflicts during the pull are about end of line charaters:
如果拉取期间的冲突是关于行尾字符:
git config --global core.autocrlf false
That should avoid any automatic eol conversion.
这应该避免任何自动 eol 转换。
You can see more in "Why does git think each line of an untouched file has changed" how to detect that situation in the working tree (git diff --word-diff-regex=.
).
您可以在“为什么 git 认为未触及文件的每一行都已更改”中了解更多信息,如何在工作树 ( git diff --word-diff-regex=.
) 中检测这种情况。