混帐树(仍然)包含重复和错误的信号13 [英] git tree (still) contains duplicates and an erroneous signal 13

查看:105
本文介绍了混帐树(仍然)包含重复和错误的信号13的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  $ git init 

经过多次添加,提交以及愤怒的键盘敲击之后,我已准备好将它推送到我的GitHub仓库中。

  $ git remote add origin git@github.com:me / Foo.git 
$ git push -u origin master
Counting对象:456,完成。
使用多达8个线程的增量压缩。
压缩对象:100%(125/125),完成。
remote:error:object c9edb23c0e6c48772785b2a7d89d08c0807b2d4a:包含重复的文件条目
remote:fatal:对象
错误:pack-objects死于信号13
错误:无法推送一些文件到'git@github.com:me / Foo.git'

git树包含重复的文件条目,并按照指示。

  $ git ls-tree c9edb> bad_tree.txt 

移除重复条目(当时只有1个!)

  $ cat bad_tree.txt | git mktree 
8ec5fe5a729ff6f71209cb9a4f75b0059c049190
$ git replace c9edb 8ec5f
$ git fsck --full
检查对象目录:100%(256/256),完成。
树中的错误c9edb23c0e6c48772785b2a7d89d08c0807b2d4a:包含重复的文件条目
检查对象:100%(457/457),完成。

好的,文章说fsck仍然会显示错误的树,但现在推送应该可以工作。让我们来修复信号13. SO文章 Can推送到GitHub的错误:包装对象死于信号13 说这是一个文件大小的事情。好的,让我们来看看。

  $ git count-objects -v 
count:0
size :0
in-pack:457
packs:1
size-pack:1910
prune-packable:0
垃圾:0
size-garbage :0

嗯,这很奇怪。它说它只有1.9MB。让我们仔细检查。

  $ du -h .git 
8.0K .git / logs / refs / heads
12K .git / logs / refs
24K .git / logs
1.9M .git / objects / pack
8.0K .git / objects / info
1.9M。 git / objects
44K .git / hooks
4.0K .git / branches
12K .git / info
4.0K .git / refs / heads
4.0K。 git / refs / tags
4.0K .git / refs / replace
16K .git / refs
2.1M .git

好的,有些事情是疯了。 Git和文件系统一致认为整个存储库只有~2MB,但我得到的信号是13。嗯。让我们再试一次。

  $ git push -u原点大师
计数对象:456,完成。
使用多达8个线程的增量压缩。
压缩对象:100%(125/125),完成。
remote:error:object c9edb23c0e6c48772785b2a7d89d08c0807b2d4a:包含重复的文件条目
remote:fatal:对象
中的错误fatal:远程端意外挂起
错误:pack-objects死于信号13
错误:未能将某些参考文献推送到'git@github.com:me / Foo.git'

Grr。 来自地狱的内容管理者的确如此。我的回购刚刚结束了吗?有没有可能只推送最后一次提交给github而没有历史记录? (并且不会让我的本地回购遥遥领先于另一个本地回购,而是复制整个过程)。 偶然地,我恰好在阅读O'Reilly Git book ,发现了一个整洁的小动作使用 git branch-filter 。我应该注意到重复项错误是由于子文件夹被添加到索引中作为一个目录和一个提交中的符号链接(我不会做)。

$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ git filter-branch --index-filter'git rm -r --cached --ignore -unmatch src / dupe'master

尽管我们刚刚从轨道中删除了子目录,

  $ git fsck 
检查对象目录:100%(256/256),完成。
树中的错误c9edb23c0e6c48772785b2a7d89d08c0807b2d4a:包含重复的文件条目
检查对象:100%(457/457),完成。

看起来git并不想放弃这个blob!这是一个简单的修复。通过克隆回购处理悬浮斑点(最安全)。

  $ cd〜/ Foo_new 
$ git clone --no-hardlinks file://〜/ Foo

- -no-hardlinks 选项可防止git使用硬链接优化克隆,并确保克隆的repo包含旧回购的所有内容的副本,因此您可以安全地删除旧回购。

  $ git fsck --full 
检查对象目录:100 %(256/256),完成。
检查对象:100%(433/433),完成。

现在我需要重设我的遥控器,因为这是一个克隆回购。

  $ git remote set-url origin git@github.com:me / Foo.git 

然后推送到github。

pre $ g $ push origin master
计数对象:433,完成。
使用多达8个线程的增量压缩。
压缩对象:100%(115/115),完成。
写作对象:100%(433/433),471.04 KiB | 0字节/秒,完成。
共计433(delta 318),重用433(delta 318)
至git@github.com:me / Foo.git
* [new branch] master - > master

成功!


I have a git repository which was constructed something like this.

$ git init

After many adds, commits, and furious keyboard-pounding, I am ready to push it to my GitHub repo.

$ git remote add origin git@github.com:me/Foo.git
$ git push -u origin master
Counting objects: 456, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (125/125), done.
remote: error: object c9edb23c0e6c48772785b2a7d89d08c0807b2d4a:contains duplicate file     entries
remote: fatal: Error in object
error: pack-objects died of signal 13
error: failed to push some refs to 'git@github.com:me/Foo.git'

Searching SO, I found the article git tree contains duplicate file entries and followed the instructions there.

$ git ls-tree c9edb > bad_tree.txt

remove duplicate entry (there was only 1!)

$ cat bad_tree.txt | git mktree
8ec5fe5a729ff6f71209cb9a4f75b0059c049190
$ git replace c9edb 8ec5f
$ git fsck --full
Checking object directories: 100% (256/256), done.
error in tree c9edb23c0e6c48772785b2a7d89d08c0807b2d4a: contains duplicate file entries
Checking objects: 100% (457/457), done.

Ok, the article said that fsck will still show the bad tree, but push should now work. Let's fix the signal 13. The SO article Can't push to GitHub error: pack-objects died of signal 13 said it's a file size thing. Ok, let's check this out.

$ git count-objects -v
count: 0
size: 0
in-pack: 457
packs: 1
size-pack: 1910
prune-packable: 0
garbage: 0
size-garbage: 0

Hmm, that's weird. It says it's only 1.9MB. Let's double-check.

$ du -h .git
8.0K    .git/logs/refs/heads
12K     .git/logs/refs
24K     .git/logs
1.9M    .git/objects/pack
8.0K    .git/objects/info
1.9M    .git/objects
44K     .git/hooks
4.0K    .git/branches
12K     .git/info
4.0K    .git/refs/heads
4.0K    .git/refs/tags
4.0K    .git/refs/replace
16K     .git/refs
2.1M    .git

Ok, something is crazy. Git and the filesystem agree that the whole repository is only ~2MB, but I'm getting signal-13 on push. Hmm. Let's try it again.

$ git push -u origin master
Counting objects: 456, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (125/125), done.
remote: error: object c9edb23c0e6c48772785b2a7d89d08c0807b2d4a:contains duplicate file     entries
remote: fatal: Error in object
fatal: The remote end hung up unexpectedly
error: pack-objects died of signal 13
error: failed to push some refs to 'git@github.com:me/Foo.git'

Grr. The "content manager from hell", indeed. Is my repo just knackered? Is there any possibility of pushing only the last commit to github without the history? (and prefereably without making my local repo a remote of another local repo and copy-pastaing the whole thing over).

解决方案

Rather serendipitously, I happen to be reading the O'Reilly Git book and found a neat little trick using git branch-filter. I should note that the duplicate entry error was due to a subfolder being added to the index both as a directory and as a symlink in a single commit (I won't be doing that again!).

$ git filter-branch --index-filter 'git rm -r --cached --ignore-unmatch src/dupe' master

Even though we've just nuked that subdirectory from orbit, the bad blob is still in the repo.

$ git fsck
Checking object directories: 100% (256/256), done.
error in tree c9edb23c0e6c48772785b2a7d89d08c0807b2d4a: contains duplicate file entries
Checking objects: 100% (457/457), done.

It looks like git doesn't want to give up that blob! That's an easy fix. Dangling blobs are (most safely) dealt with by just cloning the repo.

$ cd ~/Foo_new
$ git clone --no-hardlinks file://~/Foo

The --no-hardlinks option prevents git from optimizing the clone using hardlinks and ensures that the cloned repo contains copies of everything from the old repo so you can delete the old repo safely. A quick check shows everything is in working order now.

$ git fsck --full
Checking object directories: 100% (256/256), done.
Checking objects: 100% (433/433), done.

Now I need to reset my remotes since this is a cloned repo.

$ git remote set-url origin git@github.com:me/Foo.git

And push to github.

$ git push origin master
Counting objects: 433, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (115/115), done.
Writing objects: 100% (433/433), 471.04 KiB | 0 bytes/s, done.
Total 433 (delta 318), reused 433 (delta 318)
To git@github.com:me/Foo.git
 * [new branch]      master -> master

Success!

这篇关于混帐树(仍然)包含重复和错误的信号13的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆