Branches

Branches are snapshots of your repository that you can work on in isolation of the main repository (aka. master branch). Once checked into a branch any and all changes made will not affect the master branch until merged together.

ℹ️
Think of branches as a copy (or clone) of your repository that you can be modified in isolation until you’re ready to merge your changes with the master branch.

Branches are typically created with an end goal in mind. For example to work on a new feature or resolve an outstanding bug.

Configuration

Below are the basic commands of using branches.

# To view all local branches:
git branch

# To view all remote branches:
git branch -r

# Create a new branch:
git branch [branch-name]

# Work within that branch:
git checkout [branch-name]

# Exit the branch, back onto the master:
git checkout master

# Merge the branch back into the master branch:
git push origin [branch-name]

# To determine where the origin is located:
git config -l