You may not see it from my GitHub account but I commit and push code to various projects a lot. When you are using Git in a collaborative manner like this several problems can crop up. Let me explain how I minimize or even eliminate these problems and explain my general outlook on collaborative programming.
Importance of Branching
Even though I commit and push code often I rarely push to the master branch, or any branch controlled by another developer. That way madness lies.
I will instead create a branch for my feature, then push all my code changes to that branch. Every few hours I will pull and merge the master branch into mine. This way I can keep my code up-to-date with the rest of the team.
If a team member wants to look at the changes I’ve made they can pull down my branch and look at it without sacrificing their own code integrity or the integrity of the master branch.
The best part of working this way is that if I break something it is only broken on my branch. I won’t get yelled at by random teams because my broken code won’t affect any other branch.
Once I’m happy with my code I merge the master branch in for the last time and run unit and integration tests, fixing code until all tests pass. I then finally merge my branch back into master, thus adding my code to the main trunk.
Leave a Reply
You must be logged in to post a comment.