git push --set-upstream

我在本地建了一个分支wangxiao,开发完之后,提交代码

git add .
git commit -m '注释'
git push

出现下面的问题,这个意思是:当前分支没有与远程分支关联。
因此导致了提交代码失败。

MacBook-Pro-5:web-crm wangxiao$ git push
fatal: The current branch wangxiao has no upstream branch.
To push the current branch and set the remote as upstream, use
    git push --set-upstream origin wangxiao

解决方案:
(1)直接 git push origin wangxiao 推向制定的分支,最强暴的方法。
(2)正如上面所说关联远程分支。

git push --set-upstream origin wangxiao
origin 是默认的远程版本库名称
这样关联有一个好处,以后就不用每次git push都用第(1)种方法。
---------------------

https://blog.csdn.net/boysky0015/article/details/81007897

原文地址:https://www.cnblogs.com/twoheads/p/9836716.html