GIT Branching

How to create new branch in git?

git branch <branch_name>

Note creating new branch only creates new branch it does not switch you to that new branch. You have to do that new branch manually

Check the list of branch present for in the working repository?

git branch
* shows the working branch

You can see which branch of the project is pointing also using the command git log –oneline –decorate

git log --oneline --decorate

Switching branch?

git checkout testing
Note after switch HEAD is pointing to the testing branch

If you want a detailed map of which branch is created from which branch you can run the below command to get the graph of it.

 git log --oneline --decorate --graph --all

You can create a new branch and switch to that new branch in one line using checkout command with -b switch.

git checkout -b <new branch name>

Leave a Comment