Reputation: 13975
I am wondering if it is possible to say have a main repo with everything I need, config, application code, etc. (This is a MVC environment) and create branches from a main GIT repo with just certain models,controllers,and views.
So I would have a main repo with
applications/*
assets/*
system/*
And I would have a branch with
applications/controllers/controller_name.php
applications/model/model_name.php
applications/views/view_name.php
assets/modules/controller_name/*
Then I could merge that branch into the main repo for each new "MVC setup"
Does this make sense? And can it be done?
Upvotes: 7
Views: 8003
Reputation: 9587
Git tracks snapshots of your codebase (see also the Git parable). So whatever you want to have different from the master branch, you can track in a separate branch. If that means you will have new files in the other branch, you can do it. If that means you will have the same files, modified, you can do it.
I'm not sure what you mean "for each new MVC setup", but it seems you're thinking complicated. It seems to me you would like to have a "common basis" and then have "specific setups" based on that common basis. You can do this by having a master branch with the basis, and tracking setup-specific changes/additions/whatever in the individual setup branches.
This latter approach is often used for "product variants" in practice. You would typically develop common functionality on the master branch, and merge it into each individual branch where you want it, or you would rebase the individual branches "on top of master".
You could even get fancy and cherry-pick
individual commits from one setup-specific branch to another, but I'm digressing.
Upvotes: 3
Reputation: 526603
Git does not branch on a per-file basis, it branches on a repository basis.
That said, just because you make a branch with the entire repo doesn't mean you have to have all of the same files in each branch.
Upvotes: 8