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

然后git push origin master工作了。

其他回答

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

git push -u origin master

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

帮助我的是: 我发现我的目录和git之间的连接没有建立 所以我又做了一次: Git push -u origin main

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

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

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

Git checkout -b branchname origin/branchname

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

我有同样的问题,原因是我忘记指定分支

git push myorigin feature/23082018_my-feature_eb