Create Local Branches With GitHub Desktop


Now that you have a local copy of the repository, let’s use the steps of GitHub Flow to make a change in your project. First we will create a branch.

gif of following the directions below

  1. Within GitHub Desktop, click “Branch”, then click “New Branch”.
  2. In the Name field, type a meaningful name for your branch. Something like add-index-page will work nicely.
  3. If you have been following the directions exactly, GitHub Desktop knows to create the new branch based on master because it is the branch you were checked out to when you clicked the “New Branch” option.
  4. GitHub Desktop will automatically create your new branch and switch you to it.
Tell me why

Reviewing the GitHub Flow

Remember, we used the GitHub Flow in Introduction to GitHub, and we use it again here! :smile:

The main steps of the GitHub workflow are:

  1. Create a branch :arrow_left: (This section deals with this step.)
  2. Add commits
  3. Open a Pull Request
  4. Collaborate, and make more commits
  5. Merge the Pull Request

You learned how to create a branch in the Introduction course, too. But this time, we will do it in the local repository.

When you create a local branch, it will persist regardless of how you decide to work with your files.

Feel free to use your favorite text editor or IDE to work with your files. Rest assured that you will only be making changes on the branch you have selected.

Stuck? Open an issue in the repository for this class and mention @githubteacher for help from one of the GitHub trainers!