views:

483

answers:

2

OK, here's my problem, let me try to make it all make sense...

I've created a rails website for client X. I now have a client, Y, who wants a website that does the exact same thing as client X, but with a different skin.

Rails was perfect for this since all the skinning was in it's own folder and set apart from all the business logic. (MVC framework)

Now for version control, I'm using git since it seems to be the latest, greatest thing. I haven't spent a lot of time learning all about git so I'm a bit fresh. Anyways, what I did was I made a branch from clientXcode and called it clientYcode. I then did all the changes to the views to make it look different, and lala, the same website with a different skin.

Now here's what I don't understand about git: I've made many changes to clientXcode in the views, models, and controllers; and now I want to merge those changes into clientYcode, excluding any view changes. Since views, models, and controllers each have their own folder in rails I was hoping to be able to do something like:

git merge client_x_code 'app/controllers/*', 'app/models/*'

QUESTION 1: Is something like that possible with git? If so, how would I do it?

QUESTION 2: Was branching the best solution to make a copy (or at least the effect of a copy) of my project?

+2  A: 

The simplest course of action is to merge everything, except the content of the directory you want to keep.
You can do that by adding a merge driver in that directory, as the How do I tell git to always select my local version for conflicted merges on a specific file? question details.

With that merge driver in place, Branching is a good solution in this case.


Extract:

We have a .gitattributes file defined in the dirWithCopyMerge directory (defined only in the branch where the merge will occurs: myBranch), and we have a .git\config file which now contains a merge driver.

[merge "keepMine"]
        name = always keep mine during merge
        driver = keepMine.sh %O %A %B
VonC
+1  A: 

Well I found the easiest solution to my problem...

git checkout clientYcode
git checkout clientXcode "app/controllers/"
git checkout clientXcode "app/models/"

And that does what I want!

tybro0103
But that is only temporary in your workarea, and next time you switch branches you will have to repeat all that.
ScottJ
well I of course then do a commit to save the changes in my current branch
tybro0103