Skip to main content
Git FAQ
Frequently asked questions around Git and Version Control.
Git FAQ featured image

How to Create a Branch in Git: Local and Remote

Git makes creating and managing branches very easy. In fact, the power and flexibility of its branching model is one of the biggest advantages of Git!

You can create local branches on your machine to develop new features or work on bug fixes. Afterwards, you can publish them to any remote hosting service, such as GitHub or BitBucket, to allow your teammates to collaborate.

How Do I Create a New Branch and Start Working on It?

The fastest way to create a new branch and switch to it in one command is to use git switch -c:

$ git switch -c <new-branch>

This creates a new branch based on your current branch and switches to it immediately. If you're using a Git version older than 2.23, you can use the classic equivalent:

$ git checkout -b <new-branch>

Both commands do the same thing: they create a new branch and switch to it in a single step. The -c stands for "create" and -b stands for "branch."

Visual example:

Before:                          After:

main ● ─ ─ ─ ● ─ ● (HEAD)        main ● ─ ─ ─ ● ─ ●
                                                      \
                                          new-branch   ● (HEAD)

How Do I Create a New Branch Based on the current HEAD without Switching to It?

If you just want to create a branch without switching to it, use the git branch command with the branch name:

$ git branch <new-branch>

How Do I Create a New Branch Based on Some existing One?

If you want to base your new branch on a different existing branch and switch to it, use:

$ git switch -c <new-branch> <base-branch>

Or with the classic syntax:

$ git checkout -b <new-branch> <base-branch>

If you only want to create the branch without switching to it, use:

$ git branch <new-branch> <base-branch>


Tip

Creating Branches in Tower

If you're using the Tower Git client, you can create new branches (and merge, cherry-pick, and more) simply via drag and drop:

Learn more about Tower's drag and drop capabilities.

How Do I Create a New Branch from a Specific commit?

If you want to start your new branch based on a specific commit (not a branch), then you can provide the commit hash as the starting point:

$ git branch <new-branch> f71ac24d

How Do I Create a New Branch from a Specific tag?

You can also base your new branch on a specific tag you already have in your repository:

$ git branch <new-branch> v1.2

How Do I Create a New Branch from a remote Branch?

To create a new local branch based on a remote branch, use:

$ git switch -c <new-branch> origin/<base-branch>

Or with the classic syntax, which automatically names the local branch after the remote:

$ git checkout --track origin/<base-branch>

To create the branch without switching to it, use git branch --track:

$ git branch --track <new-branch> origin/<base-branch>

How Do I Create a New Branch in a Remote Repository?

Git does not allow creating a branch directly on a remote. Instead, you create a local branch first and then push it to publish it on the remote:

$ git push -u origin <local-branch>

The -u flag establishes a tracking connection between your local branch and the new remote branch. From that point on, you can run plain git push and git pull without specifying the remote or branch name — Git looks up the tracking relationship automatically.

To verify the remote branch was created, list your remote-tracking branches:

$ git branch -r


Tip

Publishing Branches in Tower

In case you are using the Tower Git GUI, publishing a local branch to a remote is as easy as drag and drop: in the sidebar, simply drag the local branch you want to publish and drop it onto the respective remote (usually "origin"):


How Do I Create a Feature Branch?

A feature branch is simply a regular branch you create to develop a specific feature in isolation. Create it from your main development branch:

$ git switch -c feature/user-authentication main

Or use the classic syntax:

$ git checkout -b feature/user-authentication main

Common naming conventions for feature branches:

  • feature/description — e.g., feature/login-page
  • feature/issue-number — e.g., feature/issue-42
  • bugfix/description — e.g., bugfix/header-alignment

Visual example:

main       ● ─ ● ─ ● ─ ─ ─ ─ ─ ● (merge)
                    \           /
feature/login        ● ─ ● ─ ●

For a deeper look at feature branch workflows and team collaboration patterns, check out Working with Feature Branches.

How Do I Create a Branch on GitHub?

  1. Go to your repository on GitHub
  2. Click the branch dropdown (shows your current branch)
  3. Type your new branch name
  4. Click "Create branch: from main" (or your current branch)

For more details on publishing a local branch from the command line, see the section above on creating remote branches.

The "git branch" Command Reference

The git branch command handles creating, deleting, and listing branches. Here are its most useful options:

-a -v — Lists all branches (local and remote) with their latest commit hash and message:

$ git branch -a -v
* main          609d1ee New icons for "teams" page
  feature/login 82a0f21 Add test cases
  remotes/origin/main 609d1ee New icons for "teams" page

--no-merged / --merged — Filters branches by merge status relative to your current HEAD:

$ git branch --no-merged    # branches with unintegrated changes
$ git branch --merged       # branches already merged in — safe to delete

-d <branch> / -D <branch> — Deletes a branch. Use -d for branches that are fully merged (Git refuses if not); use -D to force-delete regardless:

$ git branch -d feature/login feature/newsletter

<new-branch> [<start-point>] — Creates a new local branch, optionally from a specific commit:

$ git branch feature/logout b84f02e


Learn More

About Us

As the makers of Tower, the best Git client for Mac and Windows, we help over 100,000 users in companies like Apple, Google, Amazon, Twitter, and Ebay get the most out of Git.

Just like with Tower, our mission with this platform is to help people become better professionals.

That's why we provide our guides, videos, and cheat sheets (about version control with Git and lots of other topics) for free.