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.

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>

New on Educative
Learn to Code
Learn any Language as a beginner
Develop a human edge in an AI powered world and learn to code with AI from our beginner friendly catalog
🏆 Leaderboard
Daily Coding Challenge
Solve a new coding challenge every day and climb the leaderboard

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved