Source control with git hub/lab?

Started by
10 comments, last by Bregma 9 years, 6 months ago

Really? A new branch for every change? Never heard anyone doing that.


That's pretty much the basic rule when using git. You could even go as far as saying "master is for merging, not for developing". Just make it your goal that master is always in a decent state, builds and isn't a messy construction site.

We're using Gerrit at work, which requires all changes that get pushed to be reviewed before they get merged to master (plus, a build is automatically started to verify the project still compiles... in the future, we might make unit tests still passing a requirement as well).

We generally work on on our own local master branch day to day, but origin/master (the master branch on the central repo) is kept in a working state.

When you're happy with the state of your own local master branch, we run a script that pushes to a temporary remote branch and notifies the build server. That server then compiles your code and runs the game through a bunch of automatic tests on every platform. If all the compilation and testing passes, then the server pushes your changes into origin/master.
That's basically just a fancy system to ensure that no one pushes to origin/master unless their code actually compiles and has been tested first. You could do the same with pure discipline wink.png

Also, if you want to be nice to your co-workers, you clean up your own local master before pushing. e.g. if you've done a series of small commits relating to the same feature, you might use git rebase --interactive to squish a few of them together.

We only really use branches if you're working on a long running task, which can't be committed in part because it would breaks things, and multiple people have to collaborate on finishing it.

Advertisement

A big advantage of one branch per change is it makes bisection (searching for a change that introduced a bug) much, much easier. This is only a concern, of course, if you're developing software that might need maintaining.

One branch per change means you can engage in test-driven development by writing the failing test, then making it pass, and using the "commit early, commit often" workflow in conjunction with the "trunk always passes all tests" paradigm. These are all very good things to do, and doing them together is even better.

Stephen M. Webb
Professional Free Software Developer

This topic is closed to new replies.

Advertisement