我一直难以理解裸存储库。我到处都读到共享 repo 是一个裸 repo 。为什么它必须是一个裸仓库?它不能是协作者克隆然后推/pull 的普通存储库吗?
最佳答案
它需要是一个裸仓库,因为一个非裸仓库会有一个工作树(意味着该仓库的特定版本已 check out 并且文件可见)。
每次你推送到一个非裸仓库时,你不能保证它的工作树会反射(reflect)你正在推送的内容,因为默认情况下所述工作树将保持不变。
(想象一下,如果推送会触发工作树的更新:文件会突然发生变化,而接收端的用户没有任何控制)
这就是为什么将裸仓库作为上游仓库(您推送到的仓库)更简单的原因:无需管理/更新工作树。
在“all about "bare" repos -- what, why, and how to fix a non-bare push”中查看更多信息。
It doesn't have a checked out tree, so it just does what the "server" notionally does in a centralised VCS -- records commits, branches, etc when you push to it, and gives you the latest versions when you clone or pull from it.
关于git - git 中裸共享存储库的概念,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24115224/