git 无法拉出 b/c“您有未暂存的更改”,但状态显示没有更改
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13692429/
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
Cannot Pull b/c "You have unstaged changes", but status says there are no changes
提问by Rob Wilkerson
I'm working with a developer here who is seeing a weird issue that I've never encountered before. He's working on a repository and needs to pull the latest changes from someone else before he can push. All of his changes are committed.
我正在与这里的一位开发人员一起工作,他看到了一个我以前从未遇到过的奇怪问题。他正在一个存储库上工作,需要从其他人那里提取最新的更改,然后才能推送。他的所有更改都已提交。
$ git pull
Cannot pull with rebase: You have unstaged changes.
Please commit or stash them.
Which seems reasonable enough until...
这似乎足够合理,直到......
$ git status
# On branch master
# Your branch and 'origin/master' have diverged,
# and have 3 and 1 different commit each, respectively.
#
nothing to commit (working directory clean)
Say what?
说什么?
I've tried git reset --hard HEAD
before pulling, but the pull still fails.
我git reset --hard HEAD
在拉之前尝试过,但拉仍然失败。
Only one guy is seeing this and he's on a Mac (OSX 10.6.8). Any ideas? I'm about to pull my hair out.
只有一个人看到了这个,而且他在 Mac (OSX 10.6.8) 上。有任何想法吗?我要拔头发了。
采纳答案by Peter van der Does
Instead of
代替
git pull
try
尝试
git fetch
git rebase -p origin/master
If that doesn't work you can try
如果这不起作用,您可以尝试
git pull --no-rebase
How to check why this message occurs
如何检查出现此消息的原因
Make sure you on a branch, not a detached head. Rebasing doesn't work on a detached head.
确保你在一个分支上,而不是一个独立的头。重新定位不适用于分离的头部。
Run the following commands, the result should be no output.
运行以下命令,结果应该是没有输出。
git update-index -q --ignore-submodules --refresh
git diff-files --ignore-submodules
git diff-index --cached --ignore-submodules HEAD --
回答by Tomasz
Are you working on local filesystem or nfs share?
您是在本地文件系统还是 nfs 共享上工作?
I had exactly the same problem when I was working on nfs share.
我在处理 nfs 共享时遇到了完全相同的问题。
I have added noatime
option to the mount
command and it helped:
我noatime
在mount
命令中添加了选项,它有帮助:
mount -t nfs -o noatime,... device dir
回答by srghma
for me issue was with files in secure folder
对我来说问题是安全文件夹中的文件
only this command has shown that there are files unstaged
git diff-files --ignore-submodules
de-configure git-crypt and re-encrypt files in work tree
git-crypt lock
只有这个命令表明有文件未暂存
git diff-files --ignore-submodules
取消配置 git-crypt 并重新加密工作树中的文件
git-crypt lock
回答by Chris Beach
I had this issue when I tried to rebase a repo owned by root (and I was an unprivileged user).
当我尝试重新设置 root 拥有的 repo 时,我遇到了这个问题(我是一个非特权用户)。
回答by Raje
You can try for $ git stash then try for git pull.
您可以尝试使用 $ git stash 然后尝试使用 git pull。
回答by Chamila Chulatunga
Looks like there might be a rebase in progress. Try running git rebase --abort
first.
看起来可能正在进行 rebase。git rebase --abort
先跑步试试。
More forceful methods to clean out the local include
更强有力的清理本地的方法包括
Delete all files in the working directory (excluding the .git directory, of course)
git clean -d -x -f
(-d
: directories,-x
: ignored files,-f
: force. Replace-f
with-n
for dry run)
删除工作目录中的所有文件(当然不包括 .git 目录)
git clean -d -x -f
(-d
:目录-x
:被忽略的文件,-f
:力替换-f
与-n
预演)
And then follow up with a git reset --hard
and git checkout
.
然后跟进一个git reset --hard
和git checkout
。
One more thought is to try a git reset --hard HEAD~N
- i.e resetting a number of commits back, and hoping the pull will work and fast-forward the local.
另一个想法是尝试 a git reset --hard HEAD~N
- 即重置一些提交,并希望拉动能够工作并快进本地。