我试图把我的一个项目推到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 config --global push.default current

执行完以上命令后使用git push命令。

其他回答

我有同样的问题,原因是我忘记指定分支

git push myorigin feature/23082018_my-feature_eb

有一个简单的解决方案,为我在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

使用以下命令提交代码

git commit -m "first commit"

然后配置您的邮件id使用

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

这是我的工作

如果您定义了git push操作,那么如果命令行上没有给出refspec,远程中没有配置refspec,并且命令行上给出的任何选项都没有暗示refspec,它就会执行该操作。

尽管去做吧:

git config --global push.default current

然后

git push

我也有同样的问题

我用下面的命令解决了它

$ git branch --set-upstream develop origin/develop

它会在。git文件夹的配置文件中添加一个配置。