对于多个git项目使用单个git存储库 [英] Using a single git repository for multiple git projects

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

问题描述

我很便宜。我不想为许多github帐户支付费用。

我有一个像这样的项目结构。


  • / repo 是项目根目录。

  • / repo / project1 是我拥有Java项目的地方。 >是我有一个部署到heroku.com的Ruby / Rails项目(到一个名为hr1-fubar.heroku.com的heroku应用程序)。
  • strong>是我有另一个部署到heroku.com的Ruby / Rails项目(到一个名为hr2-fubar.heroku.com的heroku应用程序)。


所有项目(project1,herokurails1和herokurails2都在积极开发中)。



我想在某些git托管位置(例如github.com)甚至是办公室的本地git服务器上安装一个存储库。无论代码在 / repo / 中的任何位置更改,我都希望能够运行 git push github master ,并让我的整个 / repo / 树推到github。然而,我还希望能够将我的Rails应用程序部署到heroku.com,而无需将整个repo / *树推送到每个heroku应用程序。例如




  • / repo / herokurails1> git push heroku master 只会将herokurails1项目部署到heroku,在/ repo / *

  • / repo / herokurails2> git push heroku master 中的任何其他代码只会将herokurails2项目部署到heroku,而不会推送任何其他代码in / repo / *。



这可能吗?我需要设置什么特别的东西来实现这一点吗?或者我坚持使用多个git存储库?

解决方案

这很快就会变得非常笨拙(特别是因为Git不会让你推拉子目录像svn会)



我会看看不使用Github来存储项目。诸如 Bitbucket CodebaseHQ 有不同的定价模式,可能会更好地适合您,并为您提供所需的简单性。

另外,看一下像Gitosis这样的东西,它可以通过像 Gitlab


I'm cheap. I don't want to pay for many github accounts.

I have a project structure which looks something like this.

  • /repo is the project root.
  • /repo/project1 is where I have a Java project
  • /repo/herokurails1 is where I have a Ruby/Rails project which deploys to heroku.com (to a heroku app called hr1-fubar.heroku.com)
  • /repo/herokurails2 is where I have another Ruby/Rails project which deploys to heroku.com (to a heroku app called hr2-fubar.heroku.com).

All projects (project1, herokurails1, and herokurails2 are under active development).

I would like to have one repository at some git hosting place such as github.com or even a local git server in the office. Whenever code changes anywhere in /repo/, I want to be able to run "git push github master" and have my entire /repo/ tree pushed up to github.

However, I would also like to be able to deploy my rails apps to heroku.com without pushing the entire repo/* tree pushed to each heroku app. e.g.

  • /repo/herokurails1> git push heroku master would only deploy the herokurails1 project to heroku without pushing up any other code in /repo/*
  • /repo/herokurails2> git push heroku master would only deploy the herokurails2 project to heroku also without pushing up any other code in /repo/*.

Is this possible? Do I need to set up anything special to make this happen? Or am I stuck with multiple git repositories?

解决方案

This is going to get very unwieldy very quickly (especially as Git won't let you push pull sub directories like svn will)

I would look at not using Github for storing projects. Tools such as Bitbucket or CodebaseHQ have different pricing models which may well fit you better and give you the simplicity you need.

Alternatively, look at something like Gitosis, which can be made to be very Github-esque via tools like Gitlab

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

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