“git <refspec> 看起来不像参考”试图将本地分支链接到远程 Heroku 应用程序

Kur*_*eek 5 git heroku

我已经设置了一个 Heroku 应用程序,lucy-staging:

Kurts-MacBook-Pro-2:lucy kurtpeek$ git remote -v
staging https://git.heroku.com/lucy-staging.git (fetch)
staging https://git.heroku.com/lucy-staging.git (push)
Run Code Online (Sandbox Code Playgroud)

我有一个本地分支,custom-error-views我想将其推送到远程master分支staging。我正在尝试使用适用于推送 Git 子树的命令来关注https://devcenter.heroku.com/articles/multiple-environments#advanced-linking-local-branches-to-remote-appsgit push staging custom-error-views:master:

Kurts-MacBook-Pro-2:lucy kurtpeek$ git subtree push staging custom-error-views:master --prefix lucy-web/
'custom-error-views:master' does not look like a ref
Run Code Online (Sandbox Code Playgroud)

我不明白这个does not look like a ref错误;它似乎类似于development:masterHeroku 文档中的ref。谁能指出这里有什么问题?

更新

从源代码(https://github.com/github/git-msysgit/blob/master/contrib/subtree/git-subtree.sh)看来,此错误消息是专门为git subtrees抛出的。它简化为git check-ref-format返回非零错误代码的事实:

Kurts-MacBook-Pro-2:lucy kurtpeek$ git check-ref-format custom-error-views:master
Kurts-MacBook-Pro-2:lucy kurtpeek$ echo $?
1
Run Code Online (Sandbox Code Playgroud)

Kur*_*eek 5

我设法使用以下命令将子树推送到远程的主分支:

git push staging `git subtree split --prefix lucy-web staging`:master
Run Code Online (Sandbox Code Playgroud)

这可以概括如下:

git push [REMOTE_NAME] `git subtree split --prefix [SUBDIR_PATH] [BRANCH]`:master
Run Code Online (Sandbox Code Playgroud)

使用此摘要,上面的示例具有以下结构:

  • 远程名称- 暂存
  • 子目录路径- lucy-web
  • 分支-分期

这类似于How can I Push a part of my git repo to Heroku?中给出的答案之一。