The process to create a new branch a remote git starts with having this git on your local machine, so lets first clone the git. As an example, we are cloning our repository from GitHub. You have to use yours.
$ git clone https://github.com/lynxbee/git-helloworld.git$ cd git-helloworld/Check what is the default branch in cloned local code,
$ git branch
* masterCheck which all branches are available in remote git repository, this can be done using “git branch -r” command,
$ git branch -r
origin/HEAD -> origin/master
origin/master
origin/test_git_amendNow, lets say we want to create a new branch in remote git, which is based on our current cloned branch. So, in our current code the active branch is “master” so we will create branch “new_branch” with master as base branch.
$ git branch new_branchswitch to this new branch,
$ git checkout new_branchNow, push the code to remote git with “new_branch” as second argument, so the below command will create a new branch in remote git and also push the code to this newly created branch.
$ git push origin new_branchNow, you can check the newly created branch in remote git as,
$ git branch -r