Monday, June 24, 2019

Git Create Branch

I suppose that you have installed git on your machine. Now i am going to demonstrate. How to create new branch in git?
To create new branch first you have to go into that branch where you want to create new branch.

Syntax to create new branch as below mention.

$ git branch <branch_name>

Create new branch "myfisrtbranch"

$ git branch myfisrtbranch

you can check your branch created successfull. by using git branch. it will list all the branches that correspond to this repository. whre asterisk indicates the current active branch.

$ git branch

$ git branch
myfisrtbranch
* master
At this point history look like this.

Swith to branch

$ git checkout myfisrtbranch

$ git branch
Now pointer (HEAD) will be at your branch like as below.

$ git branch
* myfisrtbranch
 master
you can also create and switch in this branch by using below mention command on your local machine.

$ git checkout -b [your_new_branch_name]
Push the branch on remote

$ git push origin [your_new_branch_name]



Related Tutorial

No comments:

Post a Comment