Git branch command
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.
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>
Free Resources
Copyright ©2025 Educative, Inc. All rights reserved