FreeKB - Git git branch command
Git - git branch command

This assumes you are already cloned a repository from the source Git repo (typically called "origin") to a directory on your PC, such as the foo.git or bar.git repos.


After cloning a repository, by default, you will have a branch called "master" on your PC.


The git branch command can be used to view the shorthand name of the branch you are in. 

git branch


Something like this will be returned.The wildcard character is used to identify the branch you are currently using (master in this example).

* master


The -v or --verbose flag can be used to include the ID and comment of the latest update in the branch.

git branch --verbose


Which will return something like this.

* master f882ea7 updated logging output


The -a or -all flag can be used to display all of the branches in the repository.

git branch --all


Which will return something like this.

* master


The git checkout command can be used to switch to another branch.

git checkout feat/logging


Which should return something like this.

Switched to a new branch 'feat/logging'


Add a Comment

We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.

Please enter b28ef in the box below so that we can be sure you are a human.


Web design by yours truely - me, myself, and I   |   |