我试图把我的一个项目推到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 -u origin 'your branch name'

这段代码将在远程存储库中创建您的分支,并将它…

其他回答

在我的情况下,我有一个本地分支称为Master,而Master是在Github上。 我只是把我的Master ->重命名为Master,然后签出为Master。 然后按一下。这对我很管用。

使用以下命令提交代码

git commit -m "first commit"

然后配置您的邮件id使用

git config user.email "example@example.com"

这是我的工作

遇到了几乎相同的问题,但不是来自主分支。 我尝试推两个(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 head -u

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

你也可以使用下面的命令:

git push -u origin master

这将在远程repo中创建(-u)另一个分支。一旦使用ssh完成了身份验证。