Thursday, April 11, 2013

Git Workflow



When working on a project with multiple developers, it is very important to follow specific guidelines for revision control so that code collaboration or integration will be easier and the project's revision history will be clean. This article describes a simple version control workflow that we follow based from Github flow.
  • Keep the master branch deployable.  This means that the master branch should be kept stable and safe to deploy all the time. No one should be pushing anything on this branch instead, one should branch off of it and work on that branch.
  • Work on feature branches. When starting to work on a feature, create a branch off of master and name it descriptively (some examples of branch names:  cyclomatic-complexity-calculation,template-redesign, ticket-101-user-workdesk, etc.). Changes should be committed on the branch regularly and push to the same named branch on the remote or main repository so that everyone in the team will know what is being worked on. It is also important to keep the branch updated by rebasing to the master branch.
  • Keep your changeset clean. Do not mix unrelated features or changes in a single commit and use a commit message that clearly specify the essence of the commit. When using an issue tracker  such as that of Github, Redmine, Bitbucket and others, it is also good to add a reference to the issue being addressed in the commit message. repository
  • Commit often. With frequent commits, one can see the evolution of the code that is being worked on and it also gives one a place to go back to when something goes wrong in the current revision.
  • Review the code and merge to master. After the feature branch has been tested and when it is ready to be integrated with the development main line, merge the branch with master. When using Github, one must open a pull request and the repository maintainer will be the one to perform the merge.
  • Deploying a stable release. When the code is ready for release, it is good to tag the current revision with the release name or version or create a new branch for the release. For information on tagging, follow this link.

For further reading: