很多相关解决办法都是最后要 push 到远端的 master 上,但很多其实要求不能把个人的修改内容直接 push 到 master 主分支。

因此,当我想将本地 feature/work1 分支的修改内容 push 到远端 develop 分支时,执行了:

git push origin develop

但却发生了错误,提示为 error: src refspec master does not match any. error: failed to push some refs to ...

最后发现问题是 git push 指令的格式为:git push [remote-name(通常为 origin)] [branch-name]

当将本地分支 push 到远端同名的分支时,branchname 只需要写一个分支名就可以(如直接克隆远程分支后修改再push);

但当要 push 到的远端分支名不同于本地分支名时,需要使用 git push origin [本地分支名:远端分支名],因此,在上述出错情况下,改为执行

git push origin feature/work1:develop

然后,就发现可以正确执行了。

相关文章:

  • 2022-12-23
  • 2021-06-08
  • 2022-12-23
  • 2021-10-08
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-04-09
  • 2022-12-23
  • 2021-05-24
  • 2021-12-29
  • 2022-12-23
  • 2021-10-08
相关资源
相似解决方案