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

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

问题描述

我一直在阅读有关Git中裸露和非裸/默认存储库的信息。我无法理解(理论上)他们之间的差异,为什么我应该推到裸仓库。目前,我是唯一一个在3台不同计算机上工作的项目,但后来会有更多的人参与其中, m使用Git进行版本控制。我克隆了所有计算机上的裸回购,当我完成对其中一个计算机的修改时,我承诺并将更改推送到裸回购。从我读过的内容来看,裸仓库没有工作树,所以如果我克隆裸仓库,我不会有工作树。



我猜测工作树存储了项目中的提交信息,分支等。这不会出现在裸回购。因此,我认为使用工作树将提交推到回购似乎更好。然后,为什么我应该使用裸存储库,为什么不使用?实际的区别是什么?这对于更多从事项目工作的人是没有好处的,我猜想。



这种工作的方法是什么?建议?

解决方案

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

  derek @ derek-OptiPlex-960:〜/ Projects $ git clone --bare test裸
在/ home / derek / Projects / bare /
derek @ derek-OptiPlex-960中初始化的空Git存储库:〜/ Projects $ cd bare
derek @ derek-OptiPlex-960:〜 / Projects / bare $ git branch -a
* master
derek @ derek-OptiPlex-960:〜/ Projects / bare $ cd ..
derek @ derek-OptiPlex-960:〜/项目$ git clone non-bare
在/home/derek/Projects/non-bare/.git/中初始化的空Git存储库$ b $ cd nonderek @ derek-OptiPlex-960:〜/ Projects $ cd non -
derek @ derek-OptiPlex-960:〜/ Projects / non-bare $ git branch -a
* master
remotes / origin / HEAD - >原产地/主产地
遥控器/产地/主产地

从手册页 git clone --bare


此外,远程
的分支头直接复制到相应的
本地分支头,而不会将
映射到参/遥控器/产地/。当使用
这个选项时,
远程跟踪分支和
相关的配置变量都不会创建


假设在创建裸仓库时,Git假定裸仓库将作为多个远程用户的源存储库,所以它不会创建默认的远程原点。这意味着基本的 git pull git push 操作将不起作用,因为Git假定没有工作区,您不打算对裸仓库进行任何更改:

  derek @ derek-OptiPlex-960:〜/ Projects /裸$ git推
致命:没有配置为推送到的目的地。
derek @ derek-OptiPlex-960:〜/ Projects / bare $ git pull
致命:/ usr / lib / git-core / git-pull不能在没有工作树的情况下使用。
derek @ derek-OptiPlex-960:〜/ Projects / bare


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

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".

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?

解决方案

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

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

From the manual page for git clone --bare:

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.

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:

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

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

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