gpt4 book ai didi

Git 错误 : object xxxx: hasDot: contains '.'

转载 作者:太空狗 更新时间:2023-10-29 14:43:48 46 4
gpt4 key购买 nike

我破坏了我的(本地)git 存储库。问题来 self 的 python 脚本,该脚本添加了名称以“./”开头的文件。

当我尝试 git push 时,我得到了这个:

Counting objects: 6, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (6/6), 4.03 KiB | 0 bytes/s, done.
Total 6 (delta 1), reused 0 (delta 0)
remote: error: object a6cc7dfb40e8c513415315d6ed84143448bd4f99: hasDot: contains '.'
remote: fatal: Error in object
error: unpack failed: unpack-objects abnormal exit
To git@framagit.org:xxx/yyy.git
! [remote rejected] master -> master (unpacker error)
error: failed to push some refs to 'git@framagit.org:xxx/yyy.git'

当谷歌搜索时,唯一接近我的问题的是这个未回答的问题 SO question作者有 hasDotgit: contains '.git' 错误

我运行了 git show a6cc7dfb40e8c513415315d6ed84143448bd4f99:

./
./file1
./file2
...
file1
file2
...

git fsck --full:

warning in tree a6cc7dfb40e8c513415315d6ed84143448bd4f99: hasDot: contains '.'

我想我必须删除 git 中的 ./files 但 git rm "./file1" 删除了常规的 file1 文件,不是./file1。如果我再次运行命令,我会得到这个:

fatal: pathspec './file1' did not match any files

我不知道该怎么办,因为我在互联网上找不到任何关于这个问题的信息,甚至是 a search in the git source code没有显示任何结果。而且我宁愿在纯 git 中修复此问题,也不愿再次使用 python 模块(顺便说一句,当我尝试删除文件时,这也给了我 fatal: pathspec 错误)。

编辑 1:git ls-tree --long --abbrev --full-name a6cc7dfb40e8c513415315d6ed84143448bd4f99

040000 tree 22b75ee       -     .
100644 blob d519532 3580 file1
...
100644 blob 03e914c 6754 fileN

列表中没有./file

Edit2:如果 --full-tree 而不是 --full-name,结果相同

最佳答案

看起来如果不恢复错误的提交是不可能的。

如果其他人正在寻找 hasDothasDotgit,您可以解决这个问题:

git reset --soft fbc2d1cae724acc7b8d83442ca94088d836fea55
#delete all commits after the last good one (fbc2), but keep files (--soft)
git rm --cached "." -r -f #git rm all files but keep them locally (--cached)
git add . #git add everything back
git commit -m "msg"

关于Git 错误 : object xxxx: hasDot: contains '.' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40747758/

46 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com