我试图把我的一个项目推到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推送后经常得到以下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/

其他回答

使用以下命令提交代码

git commit -m "first commit"

然后配置您的邮件id使用

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

这是我的工作

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

我得到这个错误是因为我试图在没有写权限的情况下推送代码,我只有读权限。 在Bitbucket中,当你打开你的repo(存储库详细信息)时,你可以在右侧检查访问:

我犯了一个简单的错误,忘记了承诺:

git commit -m "first commit"

然后git push origin master工作了。

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

git push myorigin feature/23082018_my-feature_eb