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

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

问题描述

我遇到了一些关于 20 次提交的行尾问题,并且发生了一些奇怪的事情.现在 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.

和 git show ee2060 显示:

and git show ee2060 shows:

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

这使我无法推送到我的遥控器.git push 显示:

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?

推荐答案

我终于通过以下操作修复了 repo

I finally fixed the repo by doing the following

  1. 从 github 进行全新克隆,其中仅包含问题发生之前的提交
  2. 将文件系统中我搞砸的仓库添加为新克隆上的远程仓库
  3. 煞费苦心地将错误仓库中的提交检出到新克隆的工作副本中

  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

  • 依次提交每个,手动从另一个 repo 复制提交消息
  • 从遥控器中删除损坏的 repo
  • 垃圾收集+修剪

  • commit each in turn, manually copying the commit message from the other repo
  • remove the corrupt repo from remotes
  • garbage collect + prune

    git gc --aggressive --prune=now
    

  • 高兴地哭泣,因为 git fsck 没有显示重复的文件条目
  • 这篇关于git 树包含重复的文件条目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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