Reputation: 2993
I a bit confused about how I could use git branches with rails. When I start a new rails app I begin with models. I create a new branch
git checkout -b modeling
Then say I want to make a Post model, I do
git checkout -b modeling-post
When I finish with Post, I do git merge with modeling and then I do
git checkout -b modeling-comment
for the Comment model and so on.
Is this the right way? Could I do it better?
Upvotes: 0
Views: 279
Reputation: 12819
There is no such thing as a Right Way. As one would say, TIMTOWTDI: There Is More Than One Way To Do It. Your branching model on git should be what makes sense to your way of working on your code, and what enables you to be comfortable in doing so.
It's generally a good thing to have a main "release" branch that'll take in all "tested and approved" code, and fork off it when you start on a new feature. Exactly when to branch or merge is up to yo and/or your team's workflow and habits.
I personally always branch by functionality/feature, so I have my project in a given state, and people ask I add feature X, then I git branch feature-X
. Once it's done coding, I would merge it in my integ
branch to have it tested with the latest stuff my colleagues would have been working on at the same time. If it passes all tests, then it'll end up merged in master
and going for build and deployment. But then again, it depend on your working habits.
Upvotes: 3
Reputation: 96484
Forget the branches you are doing.
Branches are for functionality splits and new features that, in rails, frequently involve the whole stack.
They are also used extensively in multi-user situations but you have not described that.
Upvotes: 1
Reputation: 4499
I agree with Romain, there's no single Right Way, but it looks like you're over-complicating things...
I'd suggest to try any other more simple branching model. Romain's one looks fine to me. You also may want to take a look at this popular approach: http://nvie.com/posts/a-successful-git-branching-model/, or if you want analysis of pro et contra arguments for different branching strategies, you may find a lot of useful references here.
But if you're the only developer working at the project, and your project is at the beginning of its life cycle, then, I would say, you probably don't need branches at all.
Upvotes: 2