git tree包含重复的文件条目 [英] git tree contains duplicate file entries

查看:871
本文介绍了git tree包含重复的文件条目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一些有关20个回归的线条问题,并发生了一些奇怪的事情。现在git fsck显示:

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

和git show ee2060显示:

  File1.cs 
File2.cs
File2.cs
File2.cs
File3.cs

这是阻止我推到我的遥控器。 git push显示:

 错误:unpack failed:index-pack abnormal exit 
To https://github.com /username/Project.git
! [远程拒绝]主 - > master(n / a(unpacker error))
错误:无法推一些参考https://github.com/username/Project.git

我已经尝试重新包装和垃圾收集。我如何解决这个问题?

解决方案

我终于通过执行以下


  1. 从github执行一个新的克隆,其中只包括在问题发生之前提交的提交

  2. 将我的文件系统中的垃圾邮件添加为远程在新的克隆上

  3. 仔细检查从坏的回购到新克隆的工作副本的提交

      git checkout fe3254FIRSTCOMMITAFTERORIGIN / MASTER / HEAD。 //注意末尾的点
    //没有点,你将头移动到提交而不是提交
    //到工作副本,似乎把腐败的对象带入你的好克隆


  4. 依次提交每个依次,从另一个repo手动复制提交消息

  5. 从遥控器中删除损坏的回购

  6. 垃圾收集+修剪

      git gc --aggressive --prune = now 


  7. git fsck显示没有重复文件条目


I struggled with some line-ending problems about 20 commits back and some weird things happened. Now git fsck shows:

Checking object directories 100% (256/256), done.
error in tree ee2060e71cb36d33be5ddc1fe9ca8d7dd0ab35cd: contains duplicate file entries
Checking objects: 100% (8633/8633), done.

and git show ee2060 shows:

File1.cs
File2.cs
File2.cs
File2.cs
File3.cs

This is preventing me from pushing to my remote. git push shows:

error: unpack failed: index-pack abnormal exit
To https://github.com/username/Project.git
 ! [remote rejected] master -> master (n/a (unpacker error))
error: failed to push some refs to 'https://github.com/username/Project.git'

I have tried repacking and garbage collecting. How can I resolve this problem?

解决方案

I finally fixed the repo by doing the following

  1. do a fresh clone from github, which only included commits before the problem occurred
  2. add my messed up repo from the filesystem as a remote on the new clone
  3. painstakingly check out commits from the bad repo into the working copy of the new clone

    git checkout fe3254FIRSTCOMMITAFTERORIGIN/MASTER/HEAD . // note the dot at the end
    // without the dot, you move your head to the commit instead of the commit
    // to the working copy, and seems to bring the corrupt object into your good clone
    

  4. commit each in turn, manually copying the commit message from the other repo
  5. remove the corrupt repo from remotes
  6. garbage collect + prune

    git gc --aggressive --prune=now
    

  7. weep happily as git fsck shows no duplicate file entries

这篇关于git tree包含重复的文件条目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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