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.

TABLE OF CONTENTS


What is Branching?

[Illustration by Dev Bootcamp, Posted by dcbJen on Imgur](https://imgur.com/YG8In8X)

Illustration by Dev Bootcamp, Posted by dcbJen on Imgur

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 main or other stable production branches). It is essentially a copy of your code made at a specific point in time. That branch (or copy) 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 main 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:

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

<aside> <img src="/icons/info-alternate_gray.svg" alt="/icons/info-alternate_gray.svg" width="40px" /> Traditionally, the primary branch of a git repository was the master branch. There is a fantastic movement to move away from this and other troubling terminology prevalent in CS and tech. GitHub now automatically uses main as the default, but you may find older repositories still using master as the primary branch.

</aside>

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.