Skip to content

Try our new Crash Courses!

Buy one of our new Crash Courses, now hosted on Podia.

Create a branch – GitHub Desktop

Summary

To create a new branch in GitHub Desktop, first click the middle header that says Current Branch. Then, click the button that says New Branch. Enter a name for your branch in the dialog box that appears and click Create Branch.

If you’re creating your main work branch off of the master branch, a simple name like dev should be fine. If you’re creating a topic or feature branch, a more descriptive name might be better. For example, if you’re going to be adding an about page to a website and you’re starting a new branch to work on that, a good name for that branch might be add-about-page.

Details

When working with Git, you can use branches to separate your stable production code from your work-in-progress code.

Generally speaking, every repo has a master branch. The master branch should only contain production ready code. This means the code in your master branch shouldn’t contain any major bugs and you should be able to deploy it to a production environment (your live website or production server, for example). You shouldn’t commit directly to the master branch because of this. You should either merge commits from another branch into master locally or use pull requests.

When you’re modifying any code in your project or working on new features, you should use a separate branch. This is because your commits might contain mistakes or introduce bugs, and this could make the master branch unstable. You might also have to make several commits before a feature is production ready, and you don’t want to store incomplete work on your master branch. When the code on your separate branch is ready for production, you can merge it back into your master branch.

By default, there’s nothing stopping you from committing directly to master or from merging incomplete or broken code into your master branch, so it’s up to you to maintain these practices. For more advanced workflows, you can add tools that enforce these practices, but that won’t be covered here at this time.

References

Creating a branch for your work – GitHub Desktop

Back to: GitHub Desktop Reference