如何将普通的 Git 存储库转换为裸存储库? [英] How to convert a normal Git repository to a bare one?
问题描述
如何将普通"Git 存储库转换为裸存储库?
How can I convert a 'normal' Git repository to a bare one?
主要区别似乎是:
在普通的 Git 存储库中,存储库中有一个
.git
文件夹,其中包含所有相关数据和构成工作副本的所有其他文件
in the normal Git repository, you have a
.git
folder inside the repository containing all relevant data and all other files making up your working copy
在裸 Git 存储库中,没有工作副本,文件夹(我们称之为 repo.git
)包含实际的存储库数据
in a bare Git repository, there is no working copy and the folder (let's call it repo.git
) contains the actual repository data
推荐答案
简而言之:将repo
的内容替换为repo/.git
的内容,然后告诉存储库,它现在是一个裸存储库.
In short: replace the contents of repo
with the contents of repo/.git
, then tell the repository that it is now a bare repository.
为此,请执行以下命令:
To do this, execute the following commands:
cd repo
mv .git ../repo.git # renaming just for clarity
cd ..
rm -fr repo
cd repo.git
git config --bool core.bare true
请注意,这与对新位置执行 git clone --bare
不同(见下文).
Note that this is different from doing a git clone --bare
to a new location (see below).
这篇关于如何将普通的 Git 存储库转换为裸存储库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!