git 中裸共享存储库的概念 [英] concept of bare shared repository in git

查看:33
本文介绍了git 中裸共享存储库的概念的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在理解裸存储库方面遇到困难.我到处都读到共享仓库是一个裸仓库.为什么它必须是一个裸回购?难道不能是协作者克隆然后推/拉的普通存储库吗?

I have been facing difficulty in understanding the bare repository . I have read everywhere that a shared repo is a bare repo. Why must it be a bare repo? Can't it be a normal repo which collaborators clone and then push/pull?

推荐答案

它需要是一个裸仓库,因为一个非裸仓库会有一个工作树(意味着该仓库的特定版本被检出并且文件可见).

It needs to be a bare repo because a not bare repo would have a working tree (meaning a specific version of that repo checked out and with files visible).

每次你推送到一个非裸仓库时,你不能保证它的工作树会反映你正在推送的内容,因为默认情况下所述工作树不会被触及.
(想象一下,如果推送会触发工作树的更新:文件会突然发生变化,而接收端的用户没有任何控制)

Each time you are pushing to a non-bare repo, you have no guarantee that its working tree will reflect what you are pushing, since by default said working tree will be untouched.
(Imagine if a push would trigger an update of the working tree: the files would change all of a sudden without any control from users on the receiving end)

这就是为什么将裸存储库作为上游存储库(您推送到的存储库)更简单的原因:无需管理/更新工作树.

That is why it is simpler to have a bare repo as an upstream repo (one you push to): no working tree to manage/update.

请参阅所有关于裸"存储库——什么、为什么以及如何修复非裸推送".

它没有检出树,所以它只是做服务器"在集中式 VCS 中所做的事情——当你推送到它时记录提交、分支等,并在你推送时为你提供最新版本克隆或从中提取.

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 中裸共享存储库的概念的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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