天天看点

git push报错:The current branch master has no upstream branch问题解决

问题

进行

git push

操作时报错:

fatal: The current branch master has no upstream branch.

git push报错:The current branch master has no upstream branch问题解决

原因:没有将本地的分支与远程仓库的分支进行关联

通过

git branch

查看本地分支只有

master

git push报错:The current branch master has no upstream branch问题解决

git branch -a

查看远程分支,有

master

remotes/origin/master

两个

git push报错:The current branch master has no upstream branch问题解决

这时由于远程仓库太多,且分支较多。在默认情况下,

git push

时一般会上传到

origin

下的

master

分支上,然而当

repository

branch

过多,而又没有设置关联时,git就会产生疑问,因为它无法判断你的push目标

解决

方式一

使用

git push --set-upstream origin master

命令

方式二

git push -u origin master