10 January 2016

Remote git branch with different name

Sometimes we want to publish one of our local branches as a master branch in a new git repository.

To initialize newly created github repo add new remote. Let's name it other-repo.
git remote add other-repo https://github.com/xxx/yyy.git
To push local-branch as remote master:
git push -u other-repo local-branch:master
To later push any new commits (this can be simplified using git's config option push.default):
git push other-repo local-branch:master
To delete the tracking without deleting remote branch:
git branch local-branch --unset-upstream
To make existing local branch track existing remote branch (master):
git branch other-repo/master local-branch
To see all the trackings:
git branch -vv

git version 1.9.1

0 komentarze :

Post a Comment