Skip to main content

Posts

Showing posts with the label Creating new Branch

Git: Creating new branch on local machine and pushing to remote

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 -  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 wi...