如何从Git存储库中删除工作树 [英] How to remove working tree from a Git repository

查看:222
本文介绍了如何从Git存储库中删除工作树的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将我的Git存储库转换为裸机。我清楚地记得以前做过这个工作的git remove-tree,但是我在1.7上找不到它。你能帮我吗?






感谢你们,这是通过将回购协议移到不同的地方,然后设置the bare = true option。



这次我必须说我的记忆已经失败了。删除工作副本的技巧是我以前在Bazaar上做的:)

反正 - 感谢你的答案。

Skydreamer的答案,可能适用于你想要的,但它会丢失远程跟踪分支, .git / config 等。另一种方法是只重用 .git 目录作为裸仓库,例如通过做:

  cd my-repo 
mv .git ../my-repo.git
cd ../my-repo.git
git config core.bare true

.. 。这会使你的工作树和 my-repo.git 成为一个裸机版本的 my-repo 同一个存储库。


I'd like to convert my Git repository to a bare one. I distinctly remember something like git remove-tree that did the job previously but I can't find it on 1.7. Could you help me out?


Thanks guys, that did it with the moving of repo to a different place and then setting the bare=true option.

I must say my memory has failed me this time. The trick with removing working copy that I did previously was with Bazaar :)

Anyways - thanks for the answers.

解决方案

Cloning your git repository, as suggested in Skydreamer's answer, may be fine for what you want, but it would lose remote-tracking branches, settings in .git/config, etc. An alternative is to just reuse the .git directory as a bare repository, e.g. by doing:

cd my-repo
mv .git ../my-repo.git
cd ../my-repo.git
git config core.bare true

... which will leave my-repo with just your working tree, and my-repo.git as a bare version of the same repository.

这篇关于如何从Git存储库中删除工作树的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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