Git branch command to create, list and delete

Last updated 3 years, 2 months ago | 1057 views 75     5

Tags:- Git

Git | Git branch command to create, list, and delete

git branch command is used to create a new branch, list all branches, and delete a branch. Branches allow developers to work on the same project simultaneously

Create a new branch:

This command will create a branch locally.

git branch <branch name>
git branch new_branch

Push the new branch:

This command will push the new branch into the remote repository.

git push -u origin <branch name>
git push -u origin new_branch

View branches:

This command will list branches(the asterisk denotes the current branch).

git branch

List all branches (local and remote)

git branch -a

OR

git branch --list

Delete a branch:

This command will delete a branch

git branch -d <branch name>
git branch -d new_branch