Bare 和非 Bare 存储库之间的实际区别是什么? [英] What's the -practical- difference between a Bare and non-Bare repository?

查看:35
本文介绍了Bare 和非 Bare 存储库之间的实际区别是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在阅读有关 Git 中的裸和非裸/默认存储库的信息.我一直无法很好地理解(理论上)它们之间的差异,以及为什么我应该推"它们.到一个裸存储库.这是交易:

I've been reading about the bare and non-bare / default repositories in Git. I haven't been able to understand quite well (theoretically) the differences between them, and why I should "push" to a bare repository. Here's the deal:

目前,我是唯一一个在 3 台不同计算机上从事一个项目的人,但以后会有更多人参与其中,所以我使用 Git 进行版本控制.我在所有计算机上克隆裸存储库,当我完成对其中一台计算机的修改后,我提交并将更改推送到裸存储库.据我所知,裸仓库没有工作树",所以如果我克隆裸仓库,我将不会有工作树".

Currently, I'm the only one working on a project on 3 different computers, but there will be more people involved in it later, so I'm using Git for the version control. I clone the bare repo on all computers, and when I finish my modifications on one of them, I commit and push the changes to the bare repo. From what I've read, the bare repository does NOT have a "working tree", so if I clone the bare repo, I won't have a "working tree".

我猜测工作树存储了来自项目的提交信息、分支等.那不会出现在裸回购中.所以对我来说推"更好提交到带有工作树的 repo.

I'm guessing that the working tree stores the commit information, branches, etc. from the project. That wouldn't appear in the bare repo. So it seems better for me to "push" the commits to the repo with the working tree.

那么,为什么我应该使用裸仓库,为什么不呢?有什么实际区别?我想这对更多从事项目的人没有好处.

Then, why should I use the bare repository and why not? What's the practical difference? That would not be beneficial to more people working on a project, I suppose.

你对这种工作有什么方法?建议?

What are your methods for this kind of work? Suggestions?

推荐答案

裸仓库和非裸仓库的另一个区别是,裸仓库没有默认的远程origin仓库:>

Another difference between a bare and non-bare repository is that a bare repository does not have a default remote origin repository:

~/Projects$ git clone --bare test bare
Initialized empty Git repository in /home/derek/Projects/bare/
~/Projects$ cd bare
~/Projects/bare$ git branch -a
* master
~/Projects/bare$ cd ..
~/Projects$ git clone test non-bare
Initialized empty Git repository in /home/derek/Projects/non-bare/.git/
~/Projects$ cd non-bare
~/Projects/non-bare$ git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/master

来自 git clone --bare:

From the manual page for git clone --bare:

也是远程的分支负责人直接复制到对应的本地分行负责人,无映射他们到 refs/remotes/origin/.什么时候使用此选项,既不远程跟踪分支或相关的配置变量是已创建.

Also the branch heads at the remote are copied directly to corresponding local branch heads, without mapping them to refs/remotes/origin/. When this option is used, neither remote-tracking branches nor the related configuration variables are created.

想必,在创建裸仓库时,Git 假定裸仓库将作为多个远程用户的源仓库,因此它不会创建默认的远程源.这意味着基本的 git pullgit push 操作将不起作用,因为 Git 假设没有工作区,您不打算对裸机提交任何更改存储库:

Presumably, when it creates a bare repository, Git assumes that the bare repository will serve as the origin repository for several remote users, so it does not create the default remote origin. What this means is that basic git pull and git push operations won't work since Git assumes that without a workspace, you don't intend to commit any changes to the bare repository:

~/Projects/bare$ git push
fatal: No destination configured to push to.
~/Projects/bare$ git pull
fatal: /usr/lib/git-core/git-pull cannot be used without a working tree.
~/Projects/bare$ 

这篇关于Bare 和非 Bare 存储库之间的实际区别是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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