我正在使用 git。我尝试将现有项目推送到远程服务器。
但我每次都会遇到这个错误:
Error encountered while pushing to the remote repository: Not a valid reference 'origin/master'
如何解决这个错误?
Visual Studio 的屏幕截图:
我遇到了这个错误:
Niels@WSDH29 MINGW64 ~ (master)
$ git push https://verploe...
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 https://verpSANA.. master
如果我这样做:
Niels@WSDH29 MINGW64 ~ (master)
$ git push origin https://verpNA...:master
error: src refspec https://verploeg... does not match any.
error: failed to push some refs to 'origin'
最佳答案
出于某种原因,Visual Studio 扩展误解了来自 git 命令和/或服务器的错误消息。
这里的实际问题是你有传入的提交,应该在推送之前获取并与本地提交 merge 。不允许将多个提示推送到服务器。
如果您尝试使用 git 进行推送(而不是通过 Visual Studio),您会收到此错误消息:
! [rejected] master -> master (fetch first)
error: failed to push some refs to '.....'
因此先获取然后 merge ,或者执行 pull ,以将传入的提交与您的本地提交集成,然后您应该能够推送。
关于git - 将现有项目推送到远程服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42972070/