我试图把我的一个项目推到github,我一直得到这个错误:

peeplesoft@jane3:~/846156 (master) $ git push

fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use

     git push --set-upstream origin master

所以我试了一下,得到了这个:

peeplesoft@jane3:~/846156 (master) $ git push --set-upstream origin master

fatal: Authentication failed

另一个stackoverflow线程建议我尝试以下方法,但结果令人失望。

peeplesoft@jane3:~/846156 (master) $ git push -u origin master

fatal: Authentication failed

然后我试了一下:

peeplesoft@jane3:~/846156 (master) $ git config remote.origin.push HEAD

peeplesoft@jane3:~/846156 (master) $ git push

fatal: Authentication failed

有提示吗?


当前回答

如果您定义了git push操作,那么如果命令行上没有给出refspec,远程中没有配置refspec,并且命令行上给出的任何选项都没有暗示refspec,它就会执行该操作。

尽管去做吧:

git config --global push.default current

然后

git push

其他回答

在一个非常简单的方面,一旦你有了其他分支,你就不能只用于推一个分支

git push

但是您现在需要指定分支,即使您已经签出了想要推送的分支,所以

git push origin <feature_branch>

主分支在哪里

这是更好的,克隆这个回购新的。也许它只是迷失了方向。

我得到这个错误是因为我试图在没有写权限的情况下推送代码,我只有读权限。 在Bitbucket中,当你打开你的repo(存储库详细信息)时,你可以在右侧检查访问:

如果你在任何分支上,你可以使用这个:

git push origin head -u

这将自动在远程上创建同名的新分支。

请尝试这个场景

git push -f --set-upstream origin master