我的git
设置有一个我推送的中央存储库。今天我决定使用Git Extensions
查看中央存储库,它说repo没有提交(几乎就像从未创建过repo)。调查这个问题,我试图克隆回购,它给了我一些我从未见过的奇怪错误:
error: non-monotonic index C:/Temp/N1/Netduino/.git/objects/pack/pack-29a18084cf61cd0322a6e9cfd485ce0977348c53.idx
error: non-monotonic index C:/Temp/N1/Netduino/.git/objects/pack/pack-29a18084cf61cd0322a6e9cfd485ce0977348c53.idx
error: non-monotonic index C:/Temp/N1/Netduino/.git/objects/pack/pack-29a18084cf61cd0322a6e9cfd485ce0977348c53.idx
error: non-monotonic index C:/Temp/N1/Netduino/.git/objects/pack/pack-29a18084cf61cd0322a6e9cfd485ce0977348c53.idx
error: non-monotonic index C:/Temp/N1/Netduino/.git/objects/pack/pack-29a18084cf61cd0322a6e9cfd485ce0977348c53.idx
error: non-monotonic index C:/Temp/N1/Netduino/.git/objects/pack/pack-29a18084cf61cd0322a6e9cfd485ce0977348c53.idx
error: non-monotonic index C:/Temp/N1/Netduino/.git/objects/pack/pack-29a18084cf61cd0322a6e9cfd485ce0977348c53.idx
error: non-monotonic index C:/Temp/N1/Netduino/.git/objects/pack/pack-29a18084cf61cd0322a6e9cfd485ce0977348c53.idx
error: non-monotonic index C:/Temp/N1/Netduino/.git/objects/pack/pack-29a18084cf61cd0322a6e9cfd485ce0977348c53.idx
error: non-monotonic index C:/Temp/N1/Netduino/.git/objects/pack/pack-29a18084cf61cd0322a6e9cfd485ce0977348c53.idx
error: non-monotonic index C:/Temp/N1/Netduino/.git/objects/pack/pack-29a18084cf61cd0322a6e9cfd485ce0977348c53.idx
error: non-monotonic index C:/Temp/N1/Netduino/.git/objects/pack/pack-29a18084cf61cd0322a6e9cfd485ce0977348c53.idx
error: non-monotonic index C:/Temp/N1/Netduino/.git/objects/pack/pack-29a18084cf61cd0322a6e9cfd485ce0977348c53.idx
error: non-monotonic index C:/Temp/N1/Netduino/.git/objects/pack/pack-29a18084cf61cd0322a6e9cfd485ce0977348c53.idx
error: non-monotonic index C:/Temp/N1/Netduino/.git/objects/pack/pack-29a18084cf61cd0322a6e9cfd485ce0977348c53.idx
error: non-monotonic index C:/Temp/N1/Netduino/.git/objects/pack/pack-29a18084cf61cd0322a6e9cfd485ce0977348c53.idx
error: non-monotonic index C:/Temp/N1/Netduino/.git/objects/pack/pack-29a18084cf61cd0322a6e9cfd485ce0977348c53.idx
error: non-monotonic index C:/Temp/N1/Netduino/.git/objects/pack/pack-29a18084cf61cd0322a6e9cfd485ce0977348c53.idx
error: non-monotonic index C:/Temp/N1/Netduino/.git/objects/pack/pack-29a18084cf61cd0322a6e9cfd485ce0977348c53.idx
error: non-monotonic index C:/Temp/N1/Netduino/.git/objects/pack/pack-29a18084cf61cd0322a6e9cfd485ce0977348c53.idx
error: non-monotonic index .git/objects/pack/pack-29a18084cf61cd0322a6e9cfd485ce0977348c53.idx
error: non-monotonic index C:/Temp/N1/Netduino/.git/objects/pack/pack-29a18084cf61cd0322a6e9cfd485ce0977348c53.idx
fatal: unable to read tree cc90183a1571664f80712c0376f59afeb681303f
我在谷歌上搜索过这个问题,而且StackOverlow上还有另外一个关于这个问题的问题,但仍然没有答案(this question)。有谁能够解释这个问题?感谢
答案 0 :(得分:6)
我正在搜索此类非单一错误的信息并找到此链接:http://git.661346.n2.nabble.com/Error-non-monotonic-index-after-failed-recursive-quot-sed-quot-command-td7575014.html
TL; DR:你删除非monolotic索引,然后重新索引它。在linux中它将是:
> rm .git/objects/pack/pack-29a18084cf61cd0322a6e9cfd485ce0977348c53.idx
> git index-pack .git/objects/pack/pack-29a18084cf61cd0322a6e9cfd485ce0977348c53.pack
在此之后我不得不运行一些git gc --prune=now
和git remote prune origin
,但之前我做过其他一些操作,所以我可能已经破坏了我的回购。
答案 1 :(得分:5)
(不完整的答案,但至少有一些线索和解决方法)
该错误消息来自sha1_file.c
, method check_packed_git_idx()
,
nr = 0;
index = idx_map;
if (version > 1)
index += 2; /* skip index header */
for (i = 0; i < 256; i++) {
uint32_t n = ntohl(index[i]);
if (n < nr) {
munmap(idx_map, idx_size);
return error("non-monotonic index %s", path);
}
nr = n;
}
ntohl函数将
u_long
从TCP / IP网络顺序转换为主机字节顺序(在Intel处理器上为little-endian)。
ntohl
函数返回netlong
参数中提供的值,字节顺序颠倒过来。如果netlong
已经是主机字节顺序,那么此函数将反转它。由应用程序决定是否必须反转字节顺序。
ntohl
函数采用TCP / IP网络字节顺序(AF_INET
或AF_INET6
地址族)的32位数字,并以主机字节顺序返回32位数字。
它被称为:
在SO问题中查看包文件的结构&#34; Is the git binary diff algorithm (delta storage) standardized?&#34;:
第一个也是builtin/fsck.c
调用的,所以你可以尝试使用git fsck --full --progress,以检查你的包是否有本地损坏文件,或者它实际上是远程回购问题
确保您可以在不同的操作系统和/或不同版本的Git上复制该问题。
通常的解决方法,对于(这里的#34; Netduino&#34;)回购,似乎是在GitHub上分叉,是:
push --force
回到自己的分叉,为了删除/重置远程历史记录,可以正确打包