我试图把我的一个项目推到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 checkout -b branchname origin/branchname

在这里,默认情况下我们正在设置上游分支,因此您将不会遇到上述问题。

其他回答

使用以下命令提交代码

git commit -m "first commit"

然后配置您的邮件id使用

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

这是我的工作

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

git push origin head -u

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

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

git remote add origin url-to-your-repo

实际的指令

为了解决这个问题,在从git中检出代码时,你需要给出如下命令:

Git checkout -b branchname origin/branchname

在这里,默认情况下我们正在设置上游分支,因此您将不会遇到上述问题。

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

git commit -m "first commit"

然后git push origin master工作了。