git - 错误:路径“文件”的 addinfo_cache 失败
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/48080112/
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 - error: addinfo_cache failed for path 'file'
提问by DerWeh
When I try to merge any branch in git into master I get error: addinfo_cache failed for path 'file'
.
当我尝试将 git 中的任何分支合并到 master 时,我得到error: addinfo_cache failed for path 'file'
.
What I do:
我所做的:
>git checkout master
>git merge other-branch
Git gives me:
Git给了我:
error: addinfo_cache failed for path 'file'
file: unmerged (581c47f7d0e1a0bc825d528d9783ac18ee0cce27)
file: unmerged (26a0c24dccd2bc2f74e20488ca01bba2fcd9cf56)
file: unmerged (3be471ca5c689693339827a455f187814677642f)
fatal: git write-tree failed to write a tree
>git status
yields:
>git status
产量:
On branch master
Your branch is up-to-date with 'origin/master'.
Unmerged paths:
(use "git reset HEAD <file>..." to unstage)
(use "git add <file>..." to mark resolution)
both modified: file
no changes added to commit (use "git add" and/or "git commit -a")
I have no idea what to do and can't find anython on the problem.
我不知道该怎么做,也找不到有关此问题的任何信息。
回答by Robin Green
This error can occur when you have changed the core.autocrlf
config option but have not deleted and re-checked-out your working tree.
当您更改了core.autocrlf
配置选项但尚未删除并重新检出您的工作树时,可能会发生此错误。
So either change core.autocrlf
back to what it was, or push up your changes, delete your repo and clone it again.
因此,要么改core.autocrlf
回原来的状态,要么将更改推高,删除您的存储库并再次克隆它。
回答by Gregory A. Owen
I tried editing the above answer but it does not seem to have progressed... After looking at your comment https://stackoverflow.com/users/6950750/derweh, deleting a repo is the absolute lastresort. When quirky things seem to happen such as above. I found the best thing to do is reset to a past commit that has some considerable amount of delta and then checking back out the branch you need.
我尝试编辑上面的答案,但似乎没有进展......在查看您的评论https://stackoverflow.com/users/6950750/derweh 后,删除 repo 是绝对的最后手段。当古怪的事情似乎发生如上。我发现最好的做法是重置为过去的提交,该提交具有相当数量的增量,然后重新检出您需要的分支。
git reset HEAD~10 --hard
or git checkout some-other-branch
git reset HEAD~10 --hard
或者 git checkout some-other-branch
followed by
其次是
git checkout name-of-your-branch
git checkout name-of-your-branch
After doing this, your working branch often appears to work again.
这样做之后,您的工作分支通常会再次工作。
回答by t3rmian
I've recently encountered this error using 2.18.0.windows.1 git version when cherry-picking. The affected file wasn't even connected with the changes. Tried all the answers in this thread, tried disabling fscache and upgrading git to 2.21. Finally managed to resolve the issue by:
我最近在挑选时使用 2.18.0.windows.1 git 版本遇到了这个错误。受影响的文件甚至与更改无关。尝试了此线程中的所有答案,尝试禁用 fscache 并将 git 升级到 2.21。最后设法通过以下方式解决了问题:
- Removing the affected file
- Resetting the state with
git reset --hard origin/master
(this did not work without step 1)
- 删除受影响的文件
- 重置状态
git reset --hard origin/master
(如果没有步骤 1,这将不起作用)
回答by juwens
It's definetly somthing with the autocrlf like others allready said. But i have had it disabled ever since.
就像其他人已经说过的那样,这对 autocrlf 来说绝对是件好事。但从那以后我就禁用了它。
Sometime it's sufficient if a coworker or any tool like a mergetool or repo-frontend like gitlab, tfs, github fiddles with the line endings in a file, for example in pull requests.
有时,如果同事或任何工具(如合并工具或 repo-frontend(如 gitlab、tfs、github)在文件中摆弄行尾,例如在拉取请求中)就足够了。
easy local fix: - delete all code files - let git regenerate all files as it thinks is correct
简单的本地修复: - 删除所有代码文件 - 让 git 重新生成它认为正确的所有文件
So keep your workspace/repository with the .git folder, BUT delete all other files.
因此,将您的工作区/存储库保留在 .git 文件夹中,但删除所有其他文件。
example (all code is in src)
示例(所有代码都在 src 中)
rm -rf ./src
git reset --hard .
回答by Jonathan Root
When I had this error I simply moved the affected folders into another directory outside the repository, performed the merge, pushed the changes, moved the affected folders back, commited this and pushed it again.
当我遇到这个错误时,我只是将受影响的文件夹移动到存储库外的另一个目录中,执行合并,推送更改,将受影响的文件夹移回,提交并再次推送。
Since two folders were affected, I had to move them one by one, as git didn't inform me about the second one on the first try.
由于两个文件夹受到影响,我不得不一个一个地移动它们,因为 git 在第一次尝试时没有通知我关于第二个文件夹的信息。
It's not a nice solution, but it worked without reset or any other changes on the repository or git (I'm using git-extensions).
这不是一个很好的解决方案,但它无需重置或对存储库或 git 进行任何其他更改(我使用的是 git-extensions)。
回答by Zoltan Rajnai
I faced this same issue during a merge with "git version 2.23.0.windows.1".
Running the same merge command under Cygwin using "git version 2.17.0" worked.
我在与“git version 2.23.0.windows.1”合并时遇到了同样的问题。
使用“git version 2.17.0”在 Cygwin 下运行相同的合并命令有效。
None of the above recommendations helped me (not even doing a new clone of the repo).
以上建议都没有帮助我(甚至没有对 repo 进行新的克隆)。
回答by ogoras
- Did you try to first solve the conflicts you have on the "file" by running
git mergetool
, and afterwards merging your "other branch" into master? - Or if you don't care about you local changes to this "file" then you could just reset it hard to the remote branch
git reset --hard origin/master
and afterwards do thegit merge other-branch
- 您是否尝试首先通过运行来解决“文件”上的冲突
git mergetool
,然后将“其他分支”合并到 master 中? - 或者,如果您不关心对这个“文件”的本地更改,那么您可以将其硬重置到远程分支
git reset --hard origin/master
,然后再执行git merge other-branch