我试图把我的一个项目推到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

有提示吗?


当前回答

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

其他回答

有一个简单的解决方案,为我在macOS Sierra工作。 我就吩咐两件事:

git pull --rebase git_url(Ex: https://github.com/username/reponame.git)
git push origin master

如果在任何未来的推送之后显示任何关于upstream的致命错误,那么只需运行:

git push --set-upstream origin master

在我看来,这只是一个错误的默认git行为。 回顾了git支持的所有选项,也回顾了相关的git代码:

https://github.com/git/git/blob/140045821aa78da3a80a7d7c8f707b955e1ab40d/builtin/push.c#L188

我建议最好的解决方案是重写push default命令:

git config --global alias.pu 'push -u'

这基本上改变了推送的默认行为,所以这是有意义的。

我也有同样的问题

我用下面的命令解决了它

$ git branch --set-upstream develop origin/develop

它会在。git文件夹的配置文件中添加一个配置。

首先使用git拉原点your_branch_name 然后使用git push origin your_branch_name

请尝试这个场景

git push -f --set-upstream origin master