To create a new branch from the existing branch i.e. master branch, you need to first clone the branch/repository on your local machine.
Clone a branch -
Creating new local branch -
Push/Update local branch to remote - This step is very necessary as you have to update the local branch on remote as well. Your created branch will not be visible/updated to remote until running below command -
Now you have pushed your local branch to remote. You can list all remote branches using below command -
Below two steps are optional.
Set upstream to local branch - Below command is used to set upstream to the newly created branch. If you do not set the upstream to your created branch, all the time you commits, you will be asked to pushed on the parent branch or your branch.
Clone a branch -
git clone <complete-repository-url>
Creating new local branch -
git checkout -b <branch-name> //Creates new branch on local machine with specified name. git branch //List all the branches on local.
Push/Update local branch to remote - This step is very necessary as you have to update the local branch on remote as well. Your created branch will not be visible/updated to remote until running below command -
git push origin HEAD
Now you have pushed your local branch to remote. You can list all remote branches using below command -
git branch -r
Below two steps are optional.
Set upstream to local branch - Below command is used to set upstream to the newly created branch. If you do not set the upstream to your created branch, all the time you commits, you will be asked to pushed on the parent branch or your branch.
git branch --set-upstream-to=origin/<parent-branch-name> <current-branch-name>
Update your local branch -
git pull
Hope this will help you. Suggestions are most welcome. Keep visiting my blog :)
Comments
Post a Comment
You are responsible person and please write responsibly