This article covers how to use the command 'Git Branch'
Branches are fundamental in Git, allowing developers to simultaneously work in parallel on the same project.
The git branch command can be used to create, delete, and list branches in our repository:
git branch <branch-name>
This command creates the branch locally. The remote repository however, is still not aware of the new branch. You can synchronize the two using git push:
# The -u (upload) addition is for newly created branches that need to be uploaded. # Future pushes on the same branch won't require it. git push -u <repository-url> <branch-name>
To delete a branch locally, simply use
# Delete the branch locally git branch -d <branch-name> # Delete the branch remotely git push origin --delete <branch-name>
To view the list of local branches, you can use
git branch # Or, to be more specific git branch --list