Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

git
branch
repository

Git branch command

Educative Answers Team

Branching offers a way to work on a new feature without affecting the main codebase. Git’s branching functionality allows the creation of new branches in a project.

These new branches can then be used to test changes to code without affecting the main project code. If the changes work, the branch can be merged back with the main branch.

svg viewer

Listing current branches

Use the following command to view current branches in the code repository:

git branch

Making a new branch

The following command makes a new branch in the code repository:

git branch <branch-name>

Switching to a branch

The following command allows you to switch to a branch:

git checkout <branch-name>

Pushing the branch to Git

To push the new branch to Git, we can use the following command:

git push origin <branch-name>

RELATED TAGS

git
branch
repository
Copyright ©2022 Educative, Inc. All rights reserved
RELATED COURSES

View all Courses

Keep Exploring