致命:git-write-tree:构建树时出错
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5483213/
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
fatal: git-write-tree: error building trees
提问by malat
I did a git pull
from a shared git repository, but something went really wrong, after I tried a git revert
. Here is the situation now:
我git pull
从一个共享的 git 存储库做了一个,但是在我尝试了一个git revert
. 现在的情况是这样的:
$ git stash
Source/MediaStorageAndFileFormat/gdcmImageCodec.cxx: needs merge
Source/MediaStorageAndFileFormat/gdcmJPEGLSCodec.cxx: needs merge
Source/MediaStorageAndFileFormat/gdcmPNMCodec.cxx: needs merge
Testing/Source/DataStructureAndEncodingDefinition/Cxx/TestDS.cxx: needs merge
Utilities/socketxx/socket++/sockstream.cpp: needs merge
Source/MediaStorageAndFileFormat/gdcmImageCodec.cxx: needs merge
Source/MediaStorageAndFileFormat/gdcmJPEGLSCodec.cxx: needs merge
Source/MediaStorageAndFileFormat/gdcmPNMCodec.cxx: needs merge
Testing/Source/DataStructureAndEncodingDefinition/Cxx/TestDS.cxx: needs merge
Utilities/socketxx/socket++/sockstream.cpp: needs merge
Source/MediaStorageAndFileFormat/gdcmImageCodec.cxx: unmerged (2aafac967c35fa4e77c3086b83a3c102939ad168)
Source/MediaStorageAndFileFormat/gdcmImageCodec.cxx: unmerged (78cc95e8bae85bf8345a7793676e878e83df167b)
Source/MediaStorageAndFileFormat/gdcmImageCodec.cxx: unmerged (2524db713fbde0d7ebd86bfe2afc4b4d7d48db33)
Source/MediaStorageAndFileFormat/gdcmJPEGLSCodec.cxx: unmerged (4bb4ba78973091eaa854b03c6ce24e8f4af9e7cc)
Source/MediaStorageAndFileFormat/gdcmJPEGLSCodec.cxx: unmerged (ad0982b8b8b4c4fef23e69bbb639ca6d0cd98dd8)
Source/MediaStorageAndFileFormat/gdcmJPEGLSCodec.cxx: unmerged (4868371b7218c6e007fb6c582ad4ab226167a80a)
Source/MediaStorageAndFileFormat/gdcmPNMCodec.cxx: unmerged (f7a1b386b5b13b8fa8b6a31ce1258d2d5e5b13c5)
Source/MediaStorageAndFileFormat/gdcmPNMCodec.cxx: unmerged (6ce299c416fbb3bb60e11ef1e54962ffd3449a4c)
Source/MediaStorageAndFileFormat/gdcmPNMCodec.cxx: unmerged (75c8043a60a56a1130a34cdbd91d130bc9343c1c)
Testing/Source/DataStructureAndEncodingDefinition/Cxx/TestDS.cxx: unmerged (79c2843f2649ea9c87fa57662dafd899a5fa39ee)
...
fatal: git-write-tree: error building trees
Cannot save the current index state
Is there a way to reset all that ?
有没有办法重置所有这些?
Thanks
谢谢
回答by heracek
Use:
用:
git reset --mixed
git reset --mixed
instead of git reset --hard
. You will not lose any changes.
而不是git reset --hard
. 您不会丢失任何更改。
回答by David Rz Ayala
This worked for me:
这对我有用:
Do
做
$ git status
And check if you have Unmerged paths
并检查你是否有 Unmerged paths
# Unmerged paths:
# (use "git reset HEAD <file>..." to unstage)
# (use "git add <file>..." to mark resolution)
#
# both modified: app/assets/images/logo.png
# both modified: app/models/laundry.rb
Fix them with git add
to each of them and try git stash
again.
将它们固定到它们git add
中的每一个,然后再试git stash
一次。
git add app/assets/images/logo.png
回答by afilina
To follow up on malat's response, you can avoid losing changes by creating a patch and reapply it at a later time.
要跟进 malat 的响应,您可以通过创建补丁并稍后重新应用来避免丢失更改。
git diff --no-prefix > patch.txt
patch -p0 < patch.txt
Store your patch outside the repository folder for safety.
为安全起见,将补丁存储在存储库文件夹之外。
回答by malat
I used:
我用了:
git reset --hard
I lost some changes, but this is ok.
我丢失了一些更改,但这没关系。
回答by npeters
maybe there are some unmerged paths in your git repository that you have to resolve before stashing.
也许您的 git 存储库中有一些未合并的路径,您必须在存储之前解决这些路径。
回答by Honey
This happened for me when I was trying to stash my changes, but then my changes had conflictswith my branch's current state.
当我试图隐藏我的更改时,这发生在我身上,但是我的更改与我的分支的当前状态发生了冲突。
So I did git reset --mixed
and then resolved the git conflict and stashed again.
所以我做了git reset --mixed
然后解决了git冲突并再次隐藏。