简体   繁体   English

如何从Git存储库中删除工作树

[英]How to remove working tree from a Git repository

I'd like to convert my Git repository to a bare one. 我想将我的Git存储库转换为裸存储库。 I distinctly remember something like git remove-tree that did the job previously but I can't find it on 1.7. 我清楚地记得像之前完成这项工作的git remove-tree之类的东西但我在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. 谢谢大家,这是通过将回购移动到另一个地方然后设置bare = true选项来实现的。

I must say my memory has failed me this time. 我必须说我的记忆这次失败了。 The trick with removing working copy that I did previously was with Bazaar :) 我之前删除工作副本的诀窍是与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, eg by doing: 根据Skydreamer的回答 ,克隆你的git存储库可能对你想要的很好,但它会丢失远程跟踪分支, .git/config设置等。另一种方法是只重用.git目录作为裸存储库,例如:

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. ...将my-repo仅用你的工作树, my-repo.git作为同一存储库的裸版本。

git clone --bare old_directory new_directory

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM