简体   繁体   English

由于文件已删除,Git无法从原点拉出

[英]Git can't pull from origin because of deleted file

I try to pull from origin to update a local git repository, and got the familiar message: 我尝试从源中提取更新本地git存储库,并得到了熟悉的消息:

error: Your local changes to the following files would be overwritten by merge:
    <list of files>
Please, commit your changes or stash them before you can merge.
Aborting

Okay, no big deal. 好吧,没什么大不了的。 I stashed my changes and pulled again... and got the exact same message. 我藏了零钱,然后再次拉...并得到了完全相同的消息。 Okay, that's a bit weird. 好吧,那有点奇怪。

So I tried adding and commiting the files... and it still won't pull, for the same reason. 因此,我尝试添加和提交文件...出于同样的原因,它仍然无法拉出。

Out of frustration, I deleted the offending file. 出于沮丧,我删除了有问题的文件。 And now I still get the same error, but the file doesn't even exist anymore. 现在我仍然遇到相同的错误,但是该文件甚至不存在了。

I'm not entirely sure how to get it to stop tracking a file that doesn't exist... and I'm not sure why I can't pull from source. 我不完全确定如何获取它来停止跟踪不存在的文件...而且我不确定为什么不能从源中提取文件。

git status shows: git状态显示:

# On branch master
# Your branch is behind 'origin/master' by 249 commits, and can be fast-forwarded.
#
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#   modified:   <list of files>
#
no changes added to commit (use "git add" and/or "git commit -a")

Any suggestions? 有什么建议么?

Assuming you are in a state where you have no uncommitted changes you care about do 假设您处于没有任何未提交的更改的状态,

git reset --hard HEAD

And from the root of the repository then do 然后从存储库的根目录开始

git clean -dfx 

Then try again, and if it doesn't work post a partial of the error and the output of git status 然后重试,如果它不起作用,则发布部分错误和git status的输出

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM