git - 将现有项目推送到远程服务器

标签 git visual-studio

我正在使用 git。我尝试将现有项目推送到远程服务器。

但我每次都会遇到这个错误:

Error encountered while pushing to the remote repository: Not a valid reference 'origin/master'

如何解决这个错误?

Visual Studio 的屏幕截图:

screenshot

我遇到了这个错误:

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/

相关文章:

git - 在不更新 HEAD 的情况下 checkout 提交

git - 如何使用 tig 查看已更改但未提交的文件的差异?

git - 将新创建的特定文件夹添加到 Git 中的 .gitignore

visual-studio - 如何为 Excel 创建 GUI 插件?

javascript - 神秘的 typescript 错误

git - 不小心设置了 "remote.master.url",无法再摆脱它了吗?

c++ - 我可以将 Visual Studio 2015 头文件编译成 dll 并在 VS2013 中使用吗?

visual-studio - 您可以将启动操作/启动项目存储在 project/sln 文件中吗?

visual-studio - Visual Studio 2017 在哪里存储“开始”选项卡上列出的“最近的项目”?

git - 将文件更改从一次提交移至工作副本