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

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

其他回答

使用以下命令提交代码

git commit -m "first commit"

然后配置您的邮件id使用

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

这是我的工作

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

git push -u origin master

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

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

git push origin master

这对我有帮助。

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

如果你在尝试一个新的本地分支的git推送后经常得到以下git错误消息:

致命:当前分支没有上游分支。

要推动当前分支并将远程设置为上游,请使用

git push --set-upstream origin <branchname>

然后,问题是您没有配置git总是从本地分支创建远程的新分支。

如果你总是想在远程上创建一个新的分支来镜像和跟踪你的本地分支,永久的修复方法是:

git config --global push.default current

现在你可以毫无错误地推git了!

https://vancelucas.com/blog/how-to-fix-git-fatal-the-current-branch-has-no-upstream-branch/