Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using a single git repository for multiple git projects

Tags:

git

github

heroku

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?

like image 384
Jay Godse Avatar asked Oct 17 '11 18:10

Jay Godse


2 Answers

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

like image 167
Neil Middleton Avatar answered Oct 23 '22 20:10

Neil Middleton


You could use git subtree locally to maintain a git repository which is split from your larger repo repository, and push from that split repository. Frankly, though, I'd either use one of the free services that Adam Dymitruk suggests or just pay GitHub a bit more - they do provide an excellent service, after all...

like image 24
Mark Longair Avatar answered Oct 23 '22 20:10

Mark Longair