
To achieve that, you will run the “git checkout” command with the “-b” option and add “feature” as the branch name. $ git checkout -b Īs an example, let’s say that you want to create a new Git branch from the master branch named “feature” Next, you just have to specify the name of the branch you want to create. The easiest way to create a Git branch is to use the “git checkout” command with the “-b” option for a new branch. If you want to create a new branch as per your currently checked out (HEAD) branch, just use “git branch” with the name of the new branch as the only parameter shown below: $ git branch Creating a Git branch using checkout How do I create a new branch based on the current HEAD?

There are a variety of tasks that can perform by using the “git branch” command.
#GIT CREATE BRANCH FROM A TAG CODE#
However, developers create branches to work with a copy of the code without changing the current version. Git branching allows developers to diverge from the production version of code to fix a bug or add a feature. The default branch name in Git is master.
#GIT CREATE BRANCH FROM A TAG HOW TO#
How to create a new branch in a remote repository?Ī branch in Git is simply a lightweight movable pointer to.How to create a new branch from a remote branch?.How do I create a new branch based on the current HEAD?.Also, take a look at the main concept of today’s guide ie., How to create a Git Branch along with Git Commands. In this tutorial, you can get a deeper knowledge of Git branches and easily can understand why they chose to express this behavior in such a non-obvious manner.

When you want to add a new feature or fix a bug, you need to create a new branch to encapsulate your changes. Git branches are effectively a pointer to a snapshot of your modifications. In Git, branches are a part of your everyday development process.

As a matter of fact, the flexibility and power of its branching model is the major advantage of git. It is very easy to create and manage branches on Git for developers.
