为什么我有时会看到“条目‘文件名’不是最新的。无法合并。” 在“git reset --hard”和“git pull”之后?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/878554/
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
Why do I sometimes see an "Entry 'filename' not uptodate. Cannot merge." after a 'git reset --hard' and a 'git pull'?
提问by James Bobowski
Occasionally, when I do the following...
有时,当我执行以下操作时...
git reset --hard
HEAD is now at 0123abde comment is here
git pull
Updating 0123abde..456789fa
I get the error...
我收到错误...
error: Entry 'filename' not uptodate. Cannot merge.
The only workaround I have found is to 'git reset --hard', delete the offending file(s) then do 'git pull'. That doesn't seem right to me. Shouldn't a hard reset remove any and all local changes thus allowing me to pull the latest without any merge issues? Am I using git wrong? :)
我发现的唯一解决方法是“git reset --hard”,删除有问题的文件,然后执行“git pull”。这对我来说似乎不对。硬重置不应该删除任何和所有本地更改,从而允许我在没有任何合并问题的情况下提取最新版本吗?我使用 git 错了吗?:)
This is on a CI machine so any changes here are unwanted. I'm using git version 1.6.1.9.g97c34 on Windows Vista.
这是在 CI 机器上,所以这里的任何更改都是不需要的。我在 Windows Vista 上使用 git 版本 1.6.1.9.g97c34。
采纳答案by VonC
The general idea behind "Entry 'filename' not uptodate. Cannot merge.
" is:
“ Entry 'filename' not uptodate. Cannot merge.
”背后的总体思路是:
You have changes to files in your working directory that will be overwritten, removed or otherwise lost if the checkout and change to the new branch were to proceed.
如果要继续签出和更改新分支,您对工作目录中的文件进行了更改,这些更改将被覆盖、删除或以其他方式丢失。
It has been reportedthat this message could be "spurious" at time, (potentially because "git pull
" did not refresh the indexbefore trying to merge) but the fix was in Git1.6.1.
However, it may still be in mSysGit 1.6.1, so do you see the same error with a more recent mSysGit version ? (like 1.6.3)
据报道,此消息有时可能是“虚假的”(可能是因为“ git pull
”在尝试合并之前没有刷新索引)但修复是在 Git1.6.1 中。
但是,它可能仍在 mSysGit 1.6.1 中,那么您是否在更新的 mSysGit 版本中看到相同的错误?(如 1.6.3)
回答by vsingh
I was having the same issue and I renamed the file which was causing this and did a git pull. It pulled that missing file and fixed the issue.
我遇到了同样的问题,我重命名了导致此问题的文件并执行了 git pull。它提取了丢失的文件并解决了问题。
回答by Christophe Moine
The easiest solution I have found to this problem is:
我发现这个问题的最简单的解决方案是:
git add .
git merge --abort
回答by mochadwi
This also might happen due to using --skip-worktree
or --assume-unchanged
commands and git prevent you to do: checkout
, merge
, rebase
or pull
.
这也可能发生因使用--skip-worktree
或--assume-unchanged
命令和git阻止你做:checkout
,merge
,rebase
或pull
。
The skipped files/directory might not work if we're doing the following approach:
如果我们采用以下方法,跳过的文件/目录可能不起作用:
git stash
git merge --abort
, &git rm --cached
this also doesn't work for theskipped
file this command will throw:fatal: pathspec [file] did not match any files
instead
git stash
git merge --abort
, &git rm --cached
这也不适用skipped
于此命令将抛出的文件:fatal: pathspec [file] did not match any files
相反
Check for the solution for skipped
files here
在此处检查skipped
文件的解决方案
$: git update-index --really-refresh
<file>: needs update
Optional if you want to remove the skipped
or untracked dir/files on your local
如果要删除skipped
本地或未跟踪的目录/文件,则可选
$: git reset --hard
If none of the above commands fix the issue, you just have to undo the file from skipped
tree, e.g:
如果以上命令都没有解决问题,您只需从skipped
树中撤消文件,例如:
$: git update-index --no-skip-worktree [file]
If you skipped
the directory, just go herefor detail how to skip/undo recursively, e.g:
如果您skipped
是目录,请到此处详细了解如何递归跳过/撤消,例如:
find . -maxdepth 1 -type d \( ! -name . \) -exec bash -c "cd '{}' && pwd && git ls-files -z ${pwd} | xargs -0 git update-index --skip-worktree" \;
回答by Forklift
I had this same issue when I was trying to run
我在尝试跑步时遇到了同样的问题
git merge --abort
To get it to work, I staged the changes I didn't want. Once I did that, git was able to successfully undo them.
为了让它发挥作用,我进行了我不想要的更改。一旦我这样做了,git 就能够成功地撤消它们。