我如何将裸露的git存储库转换为正常的(就地)? [英] How do I convert a bare git repository into a normal one (in-place)?

查看:244
本文介绍了我如何将裸露的git存储库转换为正常的(就地)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个纯粹的git仓库,但需要通过ssh访问和浏览它的内容(在像用户体验这样的文件管理器中)。

我假设我可以克隆它:

  git clone -l< path_to_bare_repo> < new_normal_repo> 

但是,我的存储库大小约为20GB,我没有空间来复制它。有没有一种方法可以将裸仓库就地转换为最终的工作副本?

注意:我在一个非常简单的<1>提交存储库上测试了这一点。仔细检查一下,阅读手册页,并且在遵循StackOverflow中的建议之前,始终保持高兴。 (你做了备份,对吧?)

将一个 - bare 版本库转换为非裸:


  1. 在存储库的顶层创建一个 .git 文件夹。

  2. 将库管理事物( HEAD分支配置描述钩子信息对象引用等)移动到中。 git 你刚刚创建。

  3. 运行 git config --local --bool core.bare false 将本地git-repository转换为非裸机。

  4. (通过评论TamásPap 第3步之后,你会看到你在分支 master (或者你的主分支)上,并且你的所有文件都被删除,并且删除被暂存。这很正常。只需手工签出 master ,或者执行 git reset --hard ,即可完成。

这些步骤与这个问题,git-normal normal to bare repository - 尤其要注意这个答案 a>,其中指出上述步骤(在我假定的任一方向)与执行 git-clone 不同。但是,不确定这与你是否相关,但你在问题中提到了 git clone

I have a bare git repository, but need to access and browse its contents over ssh (in a file manager like user experience).

I assume I could clone it:

git clone -l <path_to_bare_repo> <new_normal_repo>

However, my repository is about 20GB in size and I don't have the space to duplicate it. Is there a way to convert the bare repository in-place to end up with a working copy in it?

解决方案

Note: I tested this on a very simple 1-commit repository. Double-check this, read the man pages, and always be happy you've backed up before following advice you found on StackOverflow. (You do back up, right?)

To convert a --bare repository to a non-bare:

  1. Make a .git folder in the top-level of your repository.
  2. Move the repository management things (HEAD branches config description hooks info objects refs etc.) into the .git you just created.
  3. Run git config --local --bool core.bare false to convert the local git-repository to non-bare.
  4. (via comment by Tamás Pap) After step #3 you will see that you are on branch master (or whichever your main branch is) and all your files are deleted and the deletion is staged. That's normal. Just manually checkout master, or do a git reset --hard, and you are done.

These steps are in the opposite direction of this question, "git-convert normal to bare repository" - in particular note this answer, which states that the above steps (in, I presume, either direction) is different from doing a git-clone. Not sure if that's relevant to you, though, but you mentioned git clone in the question.

这篇关于我如何将裸露的git存储库转换为正常的(就地)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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