我试图把我的一个项目推到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 myorigin feature/23082018_my-feature_eb

其他回答

使用以下命令提交代码

git commit -m "first commit"

然后配置您的邮件id使用

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

这是我的工作

对我来说,这是因为我删除了隐藏的。git文件夹。

我通过删除文件夹、重新克隆并重新进行更改来解决这个问题。

对我来说,问题来自我的分支名称:“#name-of-my-branch”,没有“#”也可以!

为了解决这个问题,在从git中检出代码时,你需要给出如下命令:

Git checkout -b branchname origin/branchname

在这里,默认情况下我们正在设置上游分支,因此您将不会遇到上述问题。

这意味着您在远程存储库中没有您的分支(您想要推送的分支),换句话说,它在远程存储库中不存在(它还没有创建)…… 所以使用以下代码:

git push -u origin 'your branch name'

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