If you’re a software engineer or developer, then you know that it’s important to keep your codebase organized and tidy. In this article, we’ll show you how to create a new branch in GitHub and then work on a project from that branch. First, open up your GitHub account and sign in. Then, select the “Branches” tab and click on the “Create Branch” button. Once you’ve clicked on the button, you’ll be taken to a page where you can enter your name and email address for your branch. You can also choose to have your branch public or private. Once you’ve entered all of these details, click on the “Create Branch” button again. Now that you’ve created a new branch in GitHub, it’s time to start working on your project from that branch! To do this, first open up your project’s settings in GitHub and select the “Branches” tab. Then, select the “New Project” option and enter a name for your new project. You can also choose to have your project public or private. Once you’ve entered all of these details, click on the “New Project” button again. Now that you’ve created a new project in GitHub, it’s time to start working on your project! To do this, first open up your project’s settings in GitHub and select the “Branches” tab. Then, select the “New Project” option and enter a name for your new project. You can also choose to have your project public or private. Once you’ve entered all of these details, click on the “New Project” button again.


Working directly in the main branch of a GitHub repository is a very dangerous thing, as you stand the risk of pushing buggy code to production. To avoid this, you should create a branch and work in that. Here’s how.

What’s a Branch, Anyway?

A branch, at its most basic, is a copy of a Git project that you can change as you like and then combine with the original project.

When you create a new repository in GitHub, there’s one branch by default—the “main” branch (previously called “master”). This, as the name implies, is the main container where your production code is stored. That is to say (in most cases, at least), if you push a change directly to the main branch, you’re making a change directly to the working product.

The problem? If you push directly to main, you run the risk of pushing buggy code to the production environment, potentially causing serious issues. That’s why you need to create a separate branch to do your work in (and then later submit that branch for review before it’s merged into the main branch).

RELATED: How Writers Can Use GitHub to Store Their Work

Create a New Branch from the GitHub Website

You can create a new branch directly from the GitHub website. First, open any browser, go to GitHub, and then open the repository that you’d like to create a branch in.

Once you’ve accessed the repository, you’ll automatically be in the “Code” tab. A bit below this, click the button that says “Main.”

A small window will appear. Give your branch a name by typing it in the text box and pressing the Enter or Return key. Words should be separated by a dash (-) or an underscore (_).

Your new branch is now created.

Create a New Branch Using the Command Line

At first glance, it might seem easier to just use GitHub from a browser, but once you get the hang of working with GitHub via the command line, things can get done so much quicker. That being said, you can do almost anything in GitHub with the command line—including creating a new branch.

But before you start, you’ll need to clone your chosen repository to your local machine. Go ahead and do that now if you haven’t already.

Once that’s done, open the command line app of your choice. This can be Terminal (if you’re a Mac user) or Command Prompt (if you’re a Windows PC user), or you can even work from the built-in command line from a text editor, such as VSCode.

Whichever app you use, you’ll need to navigate to the folder of the repo that you cloned using the cd command. From the command line, run this command:

In our example, that would look like this:

Once you’re in the proper directory, you can then create a new branch. Run this command:

Replace  with the actual name that you want to give your branch.

Your new branch is now created, but it’s only available on your local machine. You’ll need to push it to the origin repository by running this command:

Again, replace  with the actual name of your branch.

You’ve now pushed your new branch to GitHub!

Working with branches is one of the basics, but it’s also one of the most important GitHub skills to learn. Keep working to master these basics and you’ll be well on your way to becoming fluent in GitHub in no time.

RELATED: What Is GitHub, and What Is It Used For?