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

有提示吗?


当前回答

遇到了几乎相同的问题,但不是来自主分支。 我尝试推两个(2)分支到我的远程存储库,通过使用$ git push命令;不幸地抛出了:

fatal: The current branch <branch-name> has no upstream branch. To push the current branch and set the remote as upstream, use

 git push --set-upstream origin <branch-name>

我用下面的命令修复了它:

$ git push -u origin --all

PS:这里提供的解决方案应该,我相信,让git更容易远程跟踪分支;有一天,当处理有几个分支的项目时,这可能会派上用场。

其他回答

如果您试图将代码直接推到主分支,则使用命令

git push origin master

这对我有帮助。

有一个简单的解决方案,为我在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

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

在推入分支之前,请先使用此命令

git config --global push.default current

执行完以上命令后使用git push命令。

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