Git pull 是不可能的,因为你有未合并的文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29967299/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 03:09:16  来源:igfitidea点击:

Git pull is not possible because you have unmerged files

git

提问by Bhumi Shah

When I am trying to pull from git,getting below error

当我尝试从 git 中提取时,出现以下错误

Pull is not possible because you have unmerged files.
Please, fix them up in the work tree, and then use 'git add/rm <file>'
as appropriate to mark resolution, or use 'git commit -a'.

I have tried to stash changes but after stash pull is not working, asking for merge.

我试图隐藏更改,但在 stash pull 不起作用后,要求合并。

How can I pull changes without commiting/adding existing?

如何在不提交/添加现有的情况下提取更改?

回答by D.Y.

First backup the conflicted files!

首先备份冲突的文件!



Then execute:

然后执行:

git fetch origin
git reset --hard origin/master (or your branch name)


This way you should get the full git repository code if you want restore conflict file or compare them.

如果你想恢复冲突文件或比较它们,你应该通过这种方式获得完整的 git 存储库代码。

回答by iclman

Isn't it because you have an ongoing merge? Have you done

是不是因为您正在进行合并?你完成了吗

$ git merge --abort 

This will cancel the merge that was ongoing. After that, you should be able to pull. The pull might induce a new merge if some conflicts are found. Be aware that the "merge abort" will cancel any modification made in the context of the merge.

这将取消正在进行的合并。之后,您应该可以拉动。如果发现一些冲突,拉动可能会导致新的合并。请注意,“合并中止”将取消在合并上下文中所做的任何修改。

回答by SJMan

To preserve your changes as well , Commit or stash your changes first, there are some files which have conflicts. Install kdiff3 as a merge tool from the following link

为了保留您的更改,首先提交或存储您的更改,有些文件存在冲突。从以下链接安装 kdiff3 作为合并工具

When you do a git pull now, the console will show changes, type git mergetool -yand merge the changes manually.

当您现在执行 git pull 时,控制台将显示更改、git mergetool -y手动键入和合并更改。

回答by Boelensman1

I'm not sure what you want to do, but if its pulling and removing your changes, then git reset is what you need to do.

我不确定你想做什么,但如果它拉动和删除你的更改,那么 git reset 就是你需要做的。

See: http://git-scm.com/docs/git-reset

请参阅:http: //git-scm.com/docs/git-reset

What you want is probably

你想要的大概是

git reset --hard

Be warned, this will remove any changes you made to your files!

请注意,这将删除您对文件所做的任何更改!

Afterwards, the pull should work.

之后,拉动应该起作用。

回答by Matt

You can get around this by checking out a new branch and committing your changes there. Then you can force update the main branch from your remote as intended, and work on merging the code locally. But this is why doing new work in its own branch is ideal.

您可以通过签出一个新分支并在那里提交您的更改来解决这个问题。然后,您可以按预期从远程强制更新主分支,并在本地合并代码。但这就是为什么在自己的分支中做新工作是理想的。

回答by Faisal

Try with below Command:

尝试使用以下命令:

git fetch origin
git reset --hard origin/master
git pull