主存储库和本地存储库位于同一台计算机上 [英] Master repository and local repositories in the same machine

查看:95
本文介绍了主存储库和本地存储库位于同一台计算机上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Git的新手。我在linux服务器上创建了一个主存储库。同一台服务器将由5个3个用户组使用。我想为每个组创建一个本地存储库。反过来,小组成员应该为每个小组创建一个本地存储库,使用内容并将修改提交给小组的本地存储库。



我应该如何去做到这一点?

解决方案

您可以通过运行
$ b $来创建主存储库的副本b

  git clone --bare / path / to / master / repository 

放在您想要创建副本的目录中。我建议用不同的路径做5次,以创建5个不同的主存储库本地副本。然后每个组成员都可以运行

  git clone / path / to / group_local / repository 

创建其组的本地存储库的单个副本。因此,您有三个存储库级别:master,local,individual。

无论何时您克隆存储库,除非使用<$ em> c $ c> - bare 选项,git会设置克隆的 remote.origin.url 属性来引用原始文件。这意味着如果你运行

  git pull 

在克隆中,它会从原始存储库中提取更改,并且如果运行

 <$ c在克隆中,它会将克隆中的更改推送到原始目录。$ c $ g $ push 
$ / code $ / pre

所以当你的组成员在他们的个人存储库中进行修改时,他们可以运行 git push ,这些修改将被上传到他们组的本地存储库。在克隆存储库中,通过指定的URL(或预配置的远程名称),也可以从另一个存储库复制更改(我的意思是从最初克隆的存储库除外) git pull 命令。您也可以推送到任意一个其他仓库,但如果您要尝试这些仓库,还是需要注意的。


I am new to Git. I have created a master repository in a linux server. The same server is going to be used by 5 groups of 3 users each. I want to create one local repository for each group. And the group members in turn should create one local repository for each of them, play with the contents and commit the modifications to the group's local repository.

How should I go about doing this?

解决方案

You can create a copy of the master repository by running

git clone --bare /path/to/master/repository

in the directory where you want the copy to be created. I'd suggest doing this 5 times, in different paths, to create 5 different local copies of the master repository. Then each group member can run

git clone /path/to/group_local/repository

to create an individual copy of their group's local repository. So you have three "levels" of repositories: master, local, individual.

Whenever you clone a repository, unless you use the --bare option, git will set the remote.origin.url property of the clone to refer to the original. This means that if you run

git pull

in the clone, it will pull in changes from the original repository, and if you run

git push

in the clone, it will push changes from the clone to the original. So when your group members make their modifications in their individual repositories, they can run git push and those modifications will be "uploaded" to the local repository for their group. In the clone repository, it's also possible to copy changes from another repository (other than the one from which it was originally cloned, I mean) by specifying a URL (or the name of a preconfigured remote) to the git pull command. You can also push to an arbitrary other repository, although there are some things to watch out for if you're going to try that.

这篇关于主存储库和本地存储库位于同一台计算机上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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