You can do it more simply, guaranteeing that your .gitconfig
is left in a meaningful state:
Using Git version v1.8.0 and above
git push -u hub master
when pushing, or:
git branch -u hub/master
OR
(This will set the remote for the currently checked-out branch to hub/master
)
git branch --set-upstream-to hub/master
OR
(This will set the remote for the branch named branch_name
to hub/master
)
git branch branch_name --set-upstream-to hub/master
If you're using v1.7.x
or earlier
you must use --set-upstream
:
git branch --set-upstream master hub/master
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…