Ben
Ben

Reputation: 13635

A Rails project from multiple Git repositories

Is it possible to have a Rails application from multiple Git repositories? At the moment I have a main application with all my code and I manually copy paste code into it from other repositories. The other repositories are right now: A repository for my fork of Twitter Bootstrap and a repository for CSS/HTML/Javascript (frontend) code. The frontend repository is used to create a lot of tests, mainly for mobile safari. It has no database support and is only there to create and manage the frontend for my application.

I would like a setup like so:

I wish to keep these seperated repositories. Or have one with all my code but keep the seperate repositories as well.

Upvotes: 0

Views: 305

Answers (3)

nwwatson
nwwatson

Reputation: 835

There is an alternative to using git submodules if you are uncomfortable using them. You could break your application in to Engines or Railties. For example if you had a Rails 3.1 application in your gemfile you could reference an external engine like

gem 'my_gem_name', :path => '../path/to/my/custom_engine'

Likewise you can directly reference the engine through git such as

gem 'bootstrapped', :git => '[email protected]:entropillc/bootstrapped.git'

As usual, after modifying the gemfile, do a bundle install

Important note, if you are referencing a git repository then you will need to push all file changes to the remote repository for the engine and then do a 'bundle update' in the main Rails project to get the changes.

By using the local path, you will not need update your bundle.

The downside to this is that everything has to be in a gem, the plus side is that if you primarily a Rails developer reusing the gems can help you kick of project a lot quicker.

Upvotes: 1

apneadiving
apneadiving

Reputation: 115521

You'd better use git submodules, much cleaner and far less complicated.

Upvotes: 2

Andre Dublin
Andre Dublin

Reputation: 1158

Yes, you can have multiple git remotes in a local git repo. Once you make a commit you then will push to the remote repo of your choice. So to add a remote repo you'd enter this in command line

$ git remote add <remote-name> [email protected]:username/Hello-World.git

replace remote-name with what you want to call it

Then once you make a commit you'd push to the appropriate repo

also check out

How do I fork multiple projects into one repository with git?

Upvotes: 0

Related Questions