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?
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 myintegbranch 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 inmasterand going for build and deployment. But then again, it depend on your working habits.