如何解压缩打包? [英] How to unpack packed-refs?

查看:549
本文介绍了如何解压缩打包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从github克隆了一个项目,使用 git clone --mirror 。这给我留下了一个包含 packed-refs 文件, .pack .idx 文件的存储库。为了发展的目的,我想看看松散的对象,所以我解开对象与 git unpack-objects< < pack file> 这工作正常(我解压缩包文件到一个新的repo如果你想知道)。只有事情是,refs / heads / 仍然是空的,所有的refs仍然只在 packed-refs ,但我需要他们在 refs / heads /
我无法找到一个命令来提取或解压缩这些引用,我可以不知何故不相信我必须手动(或通过管道)。

I cloned a project from github with git clone --mirror. That left me with a repository with a packed-refs file, a .pack and an .idx file. For developement purposes I want to look at the loose objects, so I unpacked the objects with git unpack-objects < <pack file> which worked fine (I unpacked the pack file into a new repo if you're wondering). Only thing is that refs/heads/ is still empty, all the refs are still only in packed-refs but I need them in refs/heads/. I wasn't able to find a command that would extract or unpack those references and I can somehow not believe that I would have to do this by hand (or via pipes).

所以实际上我有两个问题:

So actually I have two questions:


  1. 有一个简单的方法来恢复 -refs

  2. 如果没有,为什么不是?如果有一个用于解包对象的命令,那么为refs不提供相同的原因是什么(不要忘记甚至有一个命令 git pack-refs ...)

  1. Is there an easy way to "restore" refs from packed-refs?
  2. If not, why isn't there? If there's a command for unpacking objects, what is the reasoning behind not providing the same for refs (don't forget that there's even a command git pack-refs...)

感谢任何提示和想法。

推荐答案

简单的答案是不 - 没有简单的方法解开refs你要求的方式。

The short answer is "no" - there is no "easy way" to unpack the refs the way you're asking.

稍长的答案是,每个ref只是一个41字节的文本文件(40字节SHA1在十六进制+换行符)在一个特定的路径,因此硬版本只需要这样在你的〜/ .gitconfig

The slightly longer answer is, each ref is just a 41-byte text file (40 byte SHA1 in hex + newline) in a specific path, so the "hard" version just requires something like this in your ~/.gitconfig:

[alias]
unpack-refs = "!bash -c 'IFS=$''\\n''; for f in $(git show-ref --heads); do /bin/echo ''Writing  '' $(echo $f | cut -c42-); echo $(echo $f | cut -c1-40) > \"${GIT_DIR:-.git}/$(echo $f | cut -c42-)\"; done'"

有一点棘手,想办法让它正常工作,但你去!现在你有'git unpack-refs',它做你期望的,作为一个奖金,甚至可以与$ GIT_DIR如果设置(否则它假设你在git树的根)。如果您还没有读过git别名,请 https://git.wiki.kernel .org / index.php /别名是一个很好的参考,甚至包括一个'git alias'扩展,你可以用它来扩展你自己的别名。

Took a little trickiness to figure out how to get it to work properly, but there you go! Now you have 'git unpack-refs' and it does what you expect, and as a bonus it even works with $GIT_DIR if that's set (otherwise it assumes you're in the root of the git tree). If you haven't read up on git aliases, https://git.wiki.kernel.org/index.php/Aliases is a great reference and even includes an example 'git alias' extension you can use to extend your own aliases.

这篇关于如何解压缩打包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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