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

其他回答

如果你在任何分支上,你可以使用这个:

git push origin head -u

这将自动在远程上创建同名的新分支。

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

我也得到了同样的错误。我想这是因为我克隆了它,并试图反击。 $ 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分支

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

显然,当您在第一次推送时忘记了——all参数时也会得到这个错误消息。我写了

git push -u origin

是谁给出了这个错误,它应该是

git push -u origin --all

哦,我多么喜欢这些复制粘贴错误……