1. Branching Defined
When you create a branch, you are essentially creating an identical copy of the project at that point in time. This isn’t the same as creating a physical copy on disk. In the background, a branch is just a pointer.
Let’s learn how you can create a new branch.
2. Creating A Branch with GitHub
Follow these steps to create a new branch in the class repository:
You will need to have collaborator access on the class repository before you can create a branch on GitHub.
- Navigate to Code tab of the class repository.
- Click the branch dropdown.
- Enter the branch name ‘github-username-caption’.
- Select the blue Create branch box or hit Enter on your keyboard.
When you create a new branch on GitHub, you are automatically switched to your branch. Now, any changes you make to the files in the repository will be applied to this new branch.
A word of caution. When you return to the repository or click the top level repository link, notice that GitHub automatically assumes you want to see the items on the default branch. If you want to continue working on a feature branch, you will need to reselect it using the branch dropdown.
3. Branching with Git
The first step in the GitHub Workflow is to create a branch. This will allow us to experiment with new features without accidentally introducing untested changes on our production branch.