git - 如何将普通的 Git 存储库转换为裸存储库?

标签 git version-control git-clone git-bare git-non-bare-repository

如何将“普通”Git 存储库转换为裸存储库?

主要区别似乎是:

  • 在普通的 Git 存储库中,存储库中有一个 .git 文件夹,其中包含所有相关数据和构成工作副本的所有其他文件

  • 在裸 Git 存储库中,没有工作副本,文件夹(我们称之为 repo.git)包含实际的存储库数据

最佳答案

简而言之:用repo/.git的内容替换repo的内容,然后告诉仓库它现在是一个裸仓库。

为此,请执行以下命令:

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(见下文)。

关于git - 如何将普通的 Git 存储库转换为裸存储库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2199897/

相关文章:

visual-studio - 了解文件的当前修订版本或 AnkhSVN 的项目/解决方案

GitHub 克隆到桌面使用 TortoiseGit 而不是 GitHub Desktop

git - 如何在网络速度有限的两个遥远站点之间同步许多小文件?我可以使用 git 来加速这项工作吗?

git - 为什么 Git 在 Cygwin 中与 Windows 7 终端有不同的配置?

sql - 如何在master分支上提交DB相关代码?

git - 保留 git Remote

git - 带有登录凭据的 Bitbucket repo 克隆

git - 如何从git中的不同远程分支 pull

git - 有没有办法从克隆的 git-svn 存储库 : 到 "git svn dcommit"

svn - 选择TFS而不是Svn/Jenkins/Jira的原因