CS 212 Software Development

CS 212-01, CS 212-02 • Fall 2019

Using Branches

Using branches in git will be extremely helpful for both homework and projects in this class. It will also come in handy outside of class; branching is used heavily in any major software development project.

What is Branching?

Git Branching

The way git tracks history is using a directed acyclic graph (DAG), which is a graph with arrows but no cycles (similar to a tree). You can think of branching as a label or pointer to a specific branch (or path) in this graph.

Still confused? Essentially, branching creates a new line of development that allows you to work on new features without disturbing other branches (like the master or other stable production branches). That branch can then be merged back into other branches when that new feature is stable.

There are several guides (linked below) that explain this concept further.

When Should You Branch?

All grading and code reviews will be done from your master branch. Use a branch any time you want to work ahead or try something out without affecting how your code will be graded. This includes:

  • Create a branch before working on homework after the deadline. This prevents the timestamp on the master branch from changing, which will trigger a late submission penalty. If you manage to get new tests passing in that branch, then it may be worthwhile to merge those changes back into master even if it does trigger the late penalty.

  • Create a branch before working ahead on projects. You may not include code in your master branch from future projects until you have fully passed code review. You are still able to make releases from other branches, so this allows you to still work ahead and pass functionality without disturbing the code review process.

In general, it is a good idea to always use branches for development and keep only stable, tested, production-ready code in the master branch.

How Should You Branch?

Learning both the command-line and the Eclipse interface is recommended. Learning the commands to branch and merge helps with understanding, and learning to perform those commands within the Eclipse interface helps avoid the amount of switching in/out of the application necessary during a normal workflow.

Here are a few guides on the topic,

Once you start branching, it is likely you will run into merge conflicts.

Do not get discouraged! Dealing with a merge conflict (or other repository issue) is like a rite-of-passage for software developers. It is frustrating for everyone! (There are many jokes and comics on this topic that are not necessarily appropriate to share in a classroom setting.)