我试图把我的一个项目推到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 config --global push.default current

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

其他回答

对我来说,我正在将更改推到一个我没有写访问权的私有回购。 在执行推或拉操作时,请确保您拥有有效的访问权限。

您可以直接验证通过

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

git push -u origin 'your branch name'

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

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

git push -u origin master

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

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

您需要先配置遥控器,然后再按。

git remote add origin url-to-your-repo

实际的指令