在 Visual Studio 中使用 Git 时出现“冲突阻止签出”错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20842750/
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
"Conflicts prevent checkout" error using Git in Visual Studio
提问by Jim Blum
I am using Git in Visual Studio. When I am trying to synchronize, the following message appears:
我在 Visual Studio 中使用 Git。当我尝试同步时,出现以下消息:
An error occured. Detailed message: An error was raised by libgit2. Cetegory = checkout(MergeConflict). 1 conflicts prevent checkout
发生错误。详细消息:libgit2 引发错误。Cetegory = 结帐(合并冲突)。1 冲突阻止结帐
I don't have a clue about what the conflicts are and how to fix them. Can anyone help me overcome this problem?
我不知道冲突是什么以及如何解决它们。谁能帮我解决这个问题?
采纳答案by Maks
I have solved the same problem by using the Git command prompt in Visual Studio, because it gives you more ability:
我已经通过在 Visual Studio 中使用 Git 命令提示符解决了同样的问题,因为它为您提供了更多能力:
http://msdn.microsoft.com/en-us/library/vstudio/dd286572.aspx
http://msdn.microsoft.com/en-us/library/vstudio/dd286572.aspx
You also may install this extension to facilitate the work with it (it gives you ability do not enter passwords each time):
您也可以安装此扩展以方便使用它(它使您不必每次都输入密码):
http://gitcredentialstore.codeplex.com/
http://gitcredentialstore.codeplex.com/
Then I used this commands:
然后我使用了这个命令:
git pull // I got an error on this step
git stash
git pull
more information about commands here:
有关命令的更多信息,请访问:
http://git-scm.com/docs/git-pull
http://git-scm.com/docs/git-pull
http://git-scm.com/book/en/Git-Tools-Stashing
http://git-scm.com/book/en/Git-Tools-Stashing
http://git-scm.com/docs/git-commit
http://git-scm.com/docs/git-commit
And as CharlesBsaid it is due to "conflict between your changes and the changes from another branch".
正如CharlesB所说,这是由于“您的更改与另一个分支的更改之间存在冲突”。
回答by Dachi
You have some uncommited changes. Commit or undo those changes and then Git "pull" will work.
您有一些未提交的更改。提交或撤消这些更改,然后 Git“拉”将起作用。
回答by Andrew Harvley-Felder
I experienced this issue during a "pull" request via Visual Studio.
我在通过 Visual Studio 发出“拉”请求期间遇到了这个问题。
There was a change to a hidden file: .ntvs_analysis.dat
隐藏文件发生了变化: .ntvs_analysis.dat
To discover this hidden file and remedy the problem, I:
为了发现这个隐藏文件并解决问题,我:
- Showed hidden files†just to see if there were changes to files that I could not see.
- In the project directory, used Git GUI to undo the change to the hidden file that I found.
- 显示隐藏文件†只是为了查看是否对我看不到的文件进行了更改。
- 在项目目录中,使用 Git GUI 撤消对我找到的隐藏文件的更改。
After that, my "pull" request was successful.
之后,我的“拉”请求成功了。
†Control Panel => Folder Options => View => Show hidden files and folders
†控制面板 => 文件夹选项 => 查看 => 显示隐藏的文件和文件夹
回答by How 'bout a Fresca
I had this issue and the way I resolved it was by "brute force"...I had no changes to commit, and no commits to sync but still got this error while trying to pull in some changes that another developer pushed.
我遇到了这个问题,我解决它的方法是“蛮力”……我没有要提交的更改,也没有要同步的提交,但是在尝试引入其他开发人员推送的一些更改时仍然出现此错误。
I ended up just whacking my local repo in the file system and re-cloning the remote branch. Voila!
我最终只是在文件系统中重击了我的本地存储库并重新克隆了远程分支。瞧!
Perhaps not the most elegant solution, but it works if you don't have any local changes that you are worried about losing.
也许不是最优雅的解决方案,但如果您没有担心丢失的任何本地更改,它就会起作用。
回答by ngm_code
This sounds like the result of not adding executables and other auto generated output from Visual Studio to a .gitignore file. You don't want to be source controlling those files. More information on this here.
这听起来像是没有将可执行文件和其他从 Visual Studio 自动生成的输出添加到 .gitignore 文件的结果。您不想成为控制这些文件的源代码。关于这方面的更多信息在这里。
回答by FatemehEbrahimiNik
if you have some changes in local then you just commit your changes and dont sync this commit
如果您在本地有一些更改,那么您只需提交更改而不同步此提交
changes => Enter a Commit Message => Commit and don't Sync this commit,then you can pull correctly
更改 => 输入提交消息 => 提交且不同步此提交,然后您可以正确拉取
if you have not changes in your branch then go on Actions => Open Comment Prompt => then enter this lines
如果您的分支中没有更改,则继续操作 => 打开评论提示 => 然后输入此行
git pull
git stash
拉
混帐
3.git pull
3.git拉
回答by Neville
Our environment requires us to not rely on Nuget auto package restore, and the problem I experienced was due to:
我们的环境要求我们不要依赖Nuget自动包还原,我遇到的问题是由于:
- Some members only use GIT command console to commit / pull / push.
- I rely on VS2013 Git tools to do Commit / pull /push.
- The Git command console pushes all the content in the packages folder
- Visual Studio tools ignores the packages folder
- 一些成员只使用 GIT 命令控制台提交/拉/推。
- 我依靠 VS2013 Git 工具来做 Commit/pull/push。
- Git命令控制台推送packages文件夹中的所有内容
- Visual Studio 工具忽略包文件夹
So the conflict was due to files in the packages folder trying to be added via the VS pull, but already existed on the HDD. For now I just deleted the relevant packages folder/files and redid the pull, that worked.
所以冲突是由于包文件夹中的文件试图通过 VS pull 添加,但已经存在于硬盘上。现在我只是删除了相关的包文件夹/文件并重新进行了拉取,这奏效了。
Hope this helps.
希望这可以帮助。