views:

120

answers:

1

Hi Everyone,

I need some advice with my desired setup with git and Rails.

Basically for my first Rails application I used a base application template from GitHub, I then made a ton of changes and now have a full application which is fairly customised.

I have now extracted all of the changes I made to the files within the base application template and have committed the changes to my fork of the github repo. Ideally, I would like to have the base application template as a branch in my application and rebase it with my master. Is this actually possible?

The reason I want to do this: I want to keep the base application up to date and functional, so for my next project I can just clone the base application template from my github fork and get working. Likewise, if anyone fixes any bugs in the base application template, I could merge those fixes with any application I have the base application template as a branch?

Is this possible? Is there a better/more common way to do this?

Thanks in advance!

Thanks,

Danny

+1  A: 

That's a interesting idea, though I think it might be harder than you realize to rebase an entire project history ontop of a bunch of updates.

Here's how you could do it, in pseudo-git :-)

# First fork the app template on github
# Then clone it locally
git clone your_fork_of_app_template_url

# Setup a remote to the original repository (the one you forked from)
git remote add original_base original_app_template_url

# make a branch at the root so you have someplace to pull in new changes
git checkout -b app_template original_base/master

# go back to your master and write your app
git checkout master
git commit
git commit 
...

# Then later update your app template if it has changed
git checkout app_template
git pull original_base

# now Rebase your entire app on top of the updated template (not sure how to go about this with multiple branches like edge)
git checkout master
git rebase app_template

This might work out if the app template was just a gem-file or a collection of plugins. But even then, you might be better off just merging master and app_template so you wouldn't have to rewrite your entire app history.

Daniel Beardsley
On top of introducing a potential mess of merge conflicts, rebasing also rewrites the history, changing the sha1s of your commits. This is a big no-no if anybody else is using your repo as a remote, and will also break associations you might have in your bug tracking system ...
grossvogel
I think I'm going to have to go back to the Git tutorials and screencasts and get a better understanding of it all.I'm sure I must be missing something!Thanks for your help!
dannymcc