一个git仓库中有多个项目? [英] Multiple projects in one git repo?

查看:860
本文介绍了一个git仓库中有多个项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在是一名SVN用户,正在将我的项目转移到git上。



我使用一个SVN存储库来存放我创建的所有项目。我的结构是这样的:

  / 
/ group1
/ subgroup1
/ project1
/ branches
...
/ tags
...
/ trunk
...
/ project2
。 ..
/ subgroup2
/ project3
...
/ project4
...
/ group2
/ subgroup3
...
/ subgroup4
...
/ lib
/ lib1
/ lib2
/ lib3

正如您所看到的,我将项目分组保存,并且 / lib 包含项目之间共享的库。

我选择了这种排序结构,因为:


  1. 使用了类似的回购结构在我学会使用SVN的公司中。

  2. 允许我拥有一个 svnserve 作为服务/守护程序在我的机器上运行,并且托管所有项目(我不喜欢文件路径方法)。



    1. 现在...至此。我在想:

      如果我转移到git,这种工作流程将如何工作?



      具体来说:


      1. 将repo树迁移到git是否简单?

      2. 假设每个项目需要单独的repo *,我将如何通过 svnserve git等价物来为他们提供所有服务(理想情况下以类似的方式分组)。 b $ b

      *)我读过关于git的内容,我明白这是事实,但我想仔细检查一下有经验的人。


      在Git中,最好让每个项目都在自己的仓库中,如果需要的话,还需要另一个仓库中的库,并将其用作子模块(相当于svn externals)在每个项目中。

      这是因为在Git中,回购是一个比SVN更轻量级的概念,更重要的是,没有能力克隆单个文件夹(不会混淆与稀疏结帐)在一个回购单独分开,就像你可以签出和工作在SVN个别文件夹。因此,如果您将所有项目都放在单个回购站中,则必须克隆所有项目。



      使用smart-http,git守护程序和ssh服务Git repos非常简单。还有用于管理多个回购(包括授权和验证)的 Gitolite 。阅读ProGit关于服务Git repos-的链接章节 - http://progit.org/book/ch4-2.html



      来到您的分组,您可以按照您的分组结构将该分配置于文件夹中,并使用智能http方法进行投放,从而使回购网址看起来像就像你会用SVN的网址一样,所有的项目都会被分组等。


      I'm an SVN user at the moment and looking at moving my projects to git.

      I use one SVN repository to hold all the projects I create. My structure is something like this:

      /
          /group1
              /subgroup1
                  /project1
                      /branches
                          ...
                      /tags
                          ...
                      /trunk
                          ...
                  /project2
                      ...
              /subgroup2
                  /project3
                      ...
                  /project4
                      ...
          /group2
              /subgroup3
                  ...
              /subgroup4
                  ...
          /lib
              /lib1
              /lib2
              /lib3
      

      As you can see I keep my projects in groups and /lib contains libraries shared between projects.

      I chose this sort structure because:

      1. Similar repo structure was used in the company where I learned to use SVN.
      2. Allows me to have an svnserve running as a service/daemon on my machine with all projects hosted on it (I don't like filepath approach).

      Now... to the point. I was wondering:

      How this sort of workflow would work if I were to move to git?

      Specifically:

      1. Would it be simple to migrate the repo tree to git?
      2. Assuming each project requires separate repo*, how would I be able to serve them all (ideally grouped in similar fashion) via svnserve git equivalent.

      *) I read about git and I understand that is the case, but I wanted to double check with experienced people.

      解决方案

      In Git, it is better to have each project in its own repo, and the libraries in another repo if needed and used as submodules ( equivalent of svn externals) in each project.

      This is because in Git, a repo is a much more lightweight concept than SVN and also, more importantly, there is no ability to clone individual folders ( not to be confused with sparse checkout) within a repo separately like you are able to checkout and work on individual folders in SVN. So if you had all projects in a single repo, you will have to clone them all.

      Serving Git repos, using smart-http, git daemon and ssh is pretty straightforward. There is also Gitolite for managing multiple repos ( including authorization and authentication). Read the linked chapter on ProGit on serving Git repos- http://progit.org/book/ch4-2.html

      Coming to your grouping, you can put the repos in folders as per your grouping structure, and serve using, say smart http method, whereby the repo urls will look like the urls that you would have used with SVN, will all projects seeming to be under the grouping etc.

      这篇关于一个git仓库中有多个项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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