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

其他回答

有一个简单的解决方案,为我在macOS Sierra工作。 我就吩咐两件事:

git pull --rebase git_url(Ex: https://github.com/username/reponame.git)
git push origin master

如果在任何未来的推送之后显示任何关于upstream的致命错误,那么只需运行:

git push --set-upstream origin master

1. 一台电脑和你的github相关联。使用SSH。计算机代码,所以你不需要提交验证输入图像说明这里

2. Git不能管理空文件夹。所以你必须写一份自述书。Md保存在一个文件中。否则您将找不到该文件。

3.您本地的项目并不是新的项目。请

git init

Git远程添加origin +“githublink”

转到添加 。

Git commit -m "" go again。

4. 然后git拉origin master(键)

5. 最后git push origin master(解决所有问题)。

http://my.oschina.net/psuyun/blog/123005 reference link

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

git push origin master

这对我有帮助。

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

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

git push -u origin

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

git push -u origin --all

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