Sunday, April 24, 2016

git branch

create new branch and push it to upstream:
git checkout -b <branch>
git push -u origin <branch>
and set <branch> to be cloned by default (<branch> may be "master" or another required branch):
git remote set-head origin <branch>

pull branch from upstream (see all branches with "git branch -a"):
git checkout <branch>

----------------------

To be able to "git diff" to branches, you need to set up necessary branches to track corresponding remote branch from origin:
  1) add information about the branch to .git/config
      git checkout <branch_name>
  2) previous command also automatically switches to the branch, so if it is necessary to return to master branch, do this
      git checkout master

No comments:

Post a Comment