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

其他回答

对我来说,这是因为我删除了隐藏的。git文件夹。

我通过删除文件夹、重新克隆并重新进行更改来解决这个问题。

在我的情况下,我有一个本地分支称为Master,而Master是在Github上。 我只是把我的Master ->重命名为Master,然后签出为Master。 然后按一下。这对我很管用。

您需要先配置遥控器,然后再按。

git remote add origin url-to-your-repo

实际的指令

使用以下命令提交代码

git commit -m "first commit"

然后配置您的邮件id使用

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

这是我的工作

不同的情况下,相同的错误(备份到外部驱动器),问题是我设置了远程回购与克隆。如果你一开始就用bare设置远程回购,每次都有效

cd F:/backups/dir
git init --bare
cd C:/working/dir
git remote add backup F:/backups/dir
git push backup master