Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"git <refspec> does not look like a ref" trying to link a local branch to a remote Heroku app

Tags:

git

heroku

I've set up a Heroku app, 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)

I have a local branch, custom-error-views, which I'd like to push to the master branch of the staging remote. I'm trying to follow https://devcenter.heroku.com/articles/multiple-environments#advanced-linking-local-branches-to-remote-apps by using the command git push staging custom-error-views:master, adapted to push a Git subtree:

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

I don't understand this does not look like a ref error; it seems analogous to the development:master ref in the Heroku documentation. Can anyone point out what is wrong here?

Update

It would appear from the source code (https://github.com/github/git-msysgit/blob/master/contrib/subtree/git-subtree.sh) that this error message is thrown specifically for git subtrees. It reduces to the fact that git check-ref-format returns a non-zero error code:

Kurts-MacBook-Pro-2:lucy kurtpeek$ git check-ref-format custom-error-views:master
Kurts-MacBook-Pro-2:lucy kurtpeek$ echo $?
1
like image 841
Kurt Peek Avatar asked Mar 12 '18 21:03

Kurt Peek


1 Answers

I managed to push the subtree to the master branch of the remote using the following command:

git push staging `git subtree split --prefix lucy-web staging`:master

This can be summarized as the following:

git push [REMOTE_NAME] `git subtree split --prefix [SUBDIR_PATH] [BRANCH]`:master

Using this summary, the example above has the following structure:

  • Remote Name - staging
  • Subdir Path - lucy-web
  • Branch - staging

This is similar to one of the answers given at How can I push a part of my git repo to Heroku?

like image 77
Kurt Peek Avatar answered Nov 11 '22 03:11

Kurt Peek