修复遗失的树 [英] Repair Missing Tree

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

问题描述

  $ git fsck --full 
我的git repo已经损坏,不幸的是它只存在于本地。检查对象目录:100%(256/256),完成。
从树上断开的链接54b4ff576b2e39831a298e58a38d91890f622b63
到树d564d0bc3dd917926892c55e3706cc116d5b165e
缺少树d564d0bc3dd917926892c55e3706cc116d5b165e

我检查了什么 d564d0bc 是,它是我的 log / 文件夹在一个rails项目中。该文件夹只包含 * .log 文件(被忽略)和一个 .gitkeep 文件。



我尝试了以下 post ,但我使用GitHub for Windows,PowerShell通过空管子尖叫着我。



任何帮助表示赞赏。

更新:我将项目复制到Linux中,因此我不必担心PowerShell命令。我仍然没有找到解决方案。

解决方案

如果您确定缺少的树只包含.gitkeep文件,它的内容比重新创建缺少的树有可能。



你需要知道的是一堆低级别的git命令?你准备好了吗?走!
首先。您需要使用 git mktree



该命令从stdin数据中读取数据并根据此信息创建一棵树。它会输出新创建的树的sha1 summ(不要忘记,以检查它是否等于d564d0bc3dd917926892c55e3706cc116d5b165e)

接下来你需要知道的事情这个输入的格式是什么?!
格式如下

 < mode> SP< type> SP< object> TAB< file> 

其中SP是空格,TAB是一个制表符。




  • 是文件模式

  • 是git对象类型(blob代表文件,树代表文件夹)
  • 是对象的sha1哈希值
  • 是文件名称



让我显示一个例子。
从该文件夹创建树(some_file文件为空)

  drwxrwxr-x 2 aleksandr aleksandr 4096 2012 -07-25 03:51。 
drwxrwxr-x 4 aleksandr aleksandr 4096 2012-07-25 03:54 ..
-rw-rw-r-- 1 aleksandr aleksandr 0 2012-07-25 03:51 some_file

您需要运行

  echo -e100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391\tsome_file| git mktree 

但是您是如何找到想要的sha1哈希? git hash-object 来拯救。
只是

  git散列对象日志/ .gitkeep 

来确定它的散列值。我认为您需要知道修复您的存储库。


My git repo has become corrupted and unfortunately it only exists locally.

$ git fsck --full
Checking object directories: 100% (256/256), done.
broken link from    tree 54b4ff576b2e39831a298e58a38d91890f622b63
              to    tree d564d0bc3dd917926892c55e3706cc116d5b165e
missing tree d564d0bc3dd917926892c55e3706cc116d5b165e

I checked into what d564d0bc is, and it is my log/ folder in a rails project. This folder only contains *.log files (which are ignored) and a .gitkeep file.

I tried following the steps mentioned in this post, but I'm using GitHub for Windows and powershell is screaming at me over an empty pipe.

Any help is appreciated.

Update: I copied the project into linux so I wouldn't have to worry about powershell commands. I still haven't found a solution though.

解决方案

If you are sure that missing tree contained only .gitkeep file and you have its content than it is possible to recreate missing tree.

All you need to know is a bunch of low-level git commands? Are you ready? Go! The first of all. You need to use git mktree.

This command reads from stdin data and creates a tree based on this information. It outputs the sha1 summ of newly created tree (Don't forget to check that it equals to d564d0bc3dd917926892c55e3706cc116d5b165e)

Next thing you need to know what the format of this input?! The format is the following

<mode> SP <type> SP <object> TAB <file>

where SP is a space, TAB is a tab.

  • is a file mode
  • is a git object type (blob for files, tree for folders)
  • is a sha1 hash of the object
  • is a file name

Let me show an example. To create the tree from this folder (the some_file file is empty)

drwxrwxr-x 2 aleksandr aleksandr 4096 2012-07-25 03:51 .
drwxrwxr-x 4 aleksandr aleksandr 4096 2012-07-25 03:54 ..
-rw-rw-r-- 1 aleksandr aleksandr    0 2012-07-25 03:51 some_file

you need to run

echo -e "100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391\tsome_file" | git mktree

But how did you find out the desired sha1 hash?! git hash-object to the rescue. Just

git hash-object log/.gitkeep

to determine its hash. I think that all you need to know to repair your repository.

这篇关于修复遗失的树的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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