5

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
Kurt Peek
  • 52,165
  • 91
  • 301
  • 526
  • 1
    I have not used `git subtree` for anything real, but it looks like `git subtree push` starts by running `git subtree split`, producing a new commit chain and producing its hash ID. `git subtree push` then pushes that hash ID to a remote reference: `git push :`. It therefore makes no sense for you to supply a local reference via a refspec: you'll get a remote-tracking name corresponding to the remote's branch name if you are pushing to a branch name on the remote and you have the appropriate `fetch` setting for the remote. – torek Mar 12 '18 at 22:34
  • I got this error and decided to update git. With git 2.33.1 - which is not yet in the default apt-get repository it seems I no longer get that error. (I currently get a remote permission error instead which feels more expected) – worldsayshi Oct 15 '21 at 10:00

1 Answers1

5

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?

Kendall
  • 1,992
  • 7
  • 28
  • 46
Kurt Peek
  • 52,165
  • 91
  • 301
  • 526
  • Hi, this does not seem to solve the question, how can you pick the branch to push with this syntax? E.g I want to push the branch "develop" instead of master? – Eric Burel May 14 '18 at 14:21