How to Create a Feature Branch in Git

Steps

Let’s demostrate the first step by creating a new feature branch from master. First I will type the following from my terminal

cd <<your git clone folder>>
git checkout master
git pull
git checkout -b feature/hyperlink

The command above will:

  1. Get the latest code from master
  2. Create a new feature branch from master, namely feature/hyperlink.

I can verify I am in my feature branch by typing:

git branch

It will highlight my current branch.

Why a Feature Branch

The followings are reasons why we make a feature branch from master:

  1. It allows me to develop my feature without impacting the others.
  2. It allows me to select a right moment, where my changes are ready and tested, to be integrated into master with other people changes to collectively make a new release.

Discussions

  1. Note the arrangement above is just one possible way of branching. As our project is simple we choose simple model.
  2. You may watch this video for some other advanced branching models.