Create and remove remote branch on GIT : As we know that the git is used to collaborate between team. Developers can share the code using git by sitting anywhere on this word, for this the code should be exist in a central repository which is accessible using network.
So follwoing is the steps to attach remote repository to local repository and push the new branch to the remote repository and also remove the remote repository on GIT.
Step 1 : Following is the command to add remote repository to the local repository:
$ git remote add origin https://git-cms.server.com/user/app.git
Step 2 : Check the remote repository added :
$ git remote -v
Step 3 : To push changes into branch of remote repository:
$ git push origin mybranch
This command will create first the new branch with name 'mybranch' on remote repository and then push the changes.
Step 4 : In case you have not the branch locally but exist in remotely or you have deleted the local branch, then you can get the copy of that branch from remote repository using following command :
$ git fetch origin mybranch:mybranch
$ git checkout mybranch
or we can also do this in following way
$ git checkout -b mybranch origin/mybranch
Step 5 : Check branches : following command show all branches exists in remote repository:
$ git branch -r :
Step 6 : Delete branch from remote repository in git:
$ git push origin :mybranch
or
$ git push origin --delete mybranch
0 Comment(s)