You can do it more simply, guaranteeing that your .gitconfig
is left in a meaningful state:
git push -u hub master
when pushing, or:
git branch -u hub/master
(This will set the remote for the currently checked-out branch to hub/master
)
git branch --set-upstream-to hub/master
(This will set the remote for the branch named branch_name
to hub/master
)
git branch branch_name --set-upstream-to hub/master
v1.7.x
or earlieryou must use --set-upstream
:
git branch --set-upstream master hub/master