Git pull 错误:您对以下文件的本地更改将被合并覆盖:
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25597104/
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
Git pull error: Your local changes to the following files would be overwritten by merge:
提问by darkgaro
I am trying to pull changes from remote branch but getting an error which doesn't make sense
我正在尝试从远程分支中提取更改但收到一个没有意义的错误
when I do
当我做
git pull
I get back
我回来了
error: Your local changes to the following files would be overwritten by merge:
file/name/path
some/more/filenamepath
Please, commit your changes or stash them before you can merge.
Aborting
Problem is I have no changes that need to be committed
When I do
git status
问题是我没有需要提交的更改
git status
# On branch master
# Your branch and 'origin/master' have diverged,
# and have 2 and 7 different commits each, respectively.
#
nothing to commit (working directory clean)
there are no working changes
I've tried git reset --hard HEAD
but that didn't help
我试过了,git reset --hard HEAD
但这没有帮助
any ideas?
有任何想法吗?
Files are on the NFS file system, maybe that has something to do with. This is on OSX
文件在 NFS 文件系统上,可能与此有关。这是在 OSX 上
Thanks
谢谢
UPDATE: This issue has to do something with NFS, because when I went to the original source and did git pull from there everything worked fine, which fixed it for this instance, but still not sure exactly why it causes issues with NFS.
更新:这个问题必须对 NFS 做一些事情,因为当我去原始源并从那里执行 git pull 时,一切正常,在这个实例中修复了它,但仍然不确定它为什么会导致 NFS 出现问题。
回答by pferg
I had this same issue, and the fetch/rebase answer didn't work for me. Here's how I solved it:
我遇到了同样的问题,fetch/rebase 答案对我不起作用。这是我解决它的方法:
I deleted the file that was causing the issue, checked it out, and then pulled successfully.
我删除了导致问题的文件,检查出来,然后成功拉取。
- rm file/name/path/some/more/filenamepath
- git checkout file/name/path/some/more/filenamepath
- git pull
- rm 文件/名称/路径/一些/更多/文件名路径
- git checkout 文件/名称/路径/一些/更多/文件名路径
- 拉
回答by Dan
- Delete the problematic files.
- Run
git reset --hard
.
- 删除有问题的文件。
- 运行
git reset --hard
。
That should fix it.
那应该解决它。
回答by VonC
You should:
你应该:
- fetch (updating all remote tracking branches, like origin/master)
- rebase your current branch on top of origin/master in order to replay your 2 commits on top of the 7 updated commits that you just fetched.
- fetch(更新所有远程跟踪分支,如 origin/master)
- 将您当前的分支重新设置在 origin/master 之上,以便在您刚刚获取的 7 个更新提交之上重放您的 2 个提交。
That would be:
那将是:
git checkout master
git fetch
git rebase origin/master
A shorter version of the above set of commands would be the following single command:
上述命令集的较短版本将是以下单个命令:
git pull --rebase
回答by Andrey Regentov
Had the same issue. Solved it by re-cloning the repo. But now I think that the reason was the line endings in these files. I played with them before.
有同样的问题。通过重新克隆 repo 解决了它。但现在我认为原因是这些文件中的行尾。我以前和他们一起玩过。
I suppose that line-ending difference doesn't mark files as changed, but may lead to this message. When you rm
the files and recheckout
them, line endings should set to "good state", and pull goes fine.
我想行尾差异不会将文件标记为已更改,但可能会导致此消息。当您rm
打开文件并重新打开checkout
它们时,行尾应设置为“良好状态”,并且拉动正常。
回答by Mihai Vlasceanu
I had the same problem but with the .idea / vcs.xml and workspace.xml files. I deleted the 2 files then used the command: - git pull "remote" "brench"
我有同样的问题,但 .idea / vcs.xml 和 workspace.xml 文件。我删除了 2 个文件,然后使用了命令:- git pull "remote" "brench"