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

有提示吗?


当前回答

遇到了几乎相同的问题,但不是来自主分支。 我尝试推两个(2)分支到我的远程存储库,通过使用$ git push命令;不幸地抛出了:

fatal: The current branch <branch-name> has no upstream branch. To push the current branch and set the remote as upstream, use

 git push --set-upstream origin <branch-name>

我用下面的命令修复了它:

$ git push -u origin --all

PS:这里提供的解决方案应该,我相信,让git更容易远程跟踪分支;有一天,当处理有几个分支的项目时,这可能会派上用场。

其他回答

这是更好的,克隆这个回购新的。也许它只是迷失了方向。

如果你在尝试一个新的本地分支的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 push myorigin feature/23082018_my-feature_eb

我也得到了同样的错误。我想这是因为我克隆了它,并试图反击。 $ git push -u origin master 这是正确的命令。试试

计数对象:8,完成。 Delta压缩使用最多2个线程。 压缩对象:100%(4/4),完成。 写入对象:100%(8/8),691字节| 46.00 KiB/s,完成。 总共8(1),重用0 (0) remote: resolved deltas: 100% (1/1), done。

[新分支]master -> master 分支主机设置为从原点跟踪远程分支主机。 它很成功。尝试创建新的u分支

遇到了几乎相同的问题,但不是来自主分支。 我尝试推两个(2)分支到我的远程存储库,通过使用$ git push命令;不幸地抛出了:

fatal: The current branch <branch-name> has no upstream branch. To push the current branch and set the remote as upstream, use

 git push --set-upstream origin <branch-name>

我用下面的命令修复了它:

$ git push -u origin --all

PS:这里提供的解决方案应该,我相信,让git更容易远程跟踪分支;有一天,当处理有几个分支的项目时,这可能会派上用场。