Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to push a subtree to heroku using a non master branch

Tags:

git

heroku

I know I can do this:

git subtree push --prefix server heroku master

to push a subtree of my project (in this case everything under the ./server directory).

And I can do the following to push a non master branch:

git push heroku somebranch:master

But I cannot seem to do any combination that looks like this to push a non master subtree:

git subtree push --prefix server heroku somebranch:master

I get:

'somebranch:master' does not look like a ref

I would so like to do this!

like image 903
Robert Moskal Avatar asked Feb 22 '16 21:02

Robert Moskal


2 Answers

On my machine running Git 2.7.1 the documentation for git subtree push says

Does a split (see below) using the <prefix> supplied and then does a git push to push the result to the repository and ref. This can be used to push your subtree to different branches of the remote repository.

There is little mention of branches at all in the documentation for git subtree, and none of the cases where branches are mentioned fit your use case.

Reading between the lines it looks like the source branch is whatever you have checked out:

git checkout somebranch
git subtree push --prefix server heroku master

And indeed you confirmed in comments that this works.

like image 181
Chris Avatar answered Sep 20 '22 17:09

Chris


The above answer will eventually run into problems.. When other people push. You can use the following command - I make it an alias - which will achieve the same aim, but allow deployments by multiple people.

git push heroku $(git subtree split --prefix=server $(git symbolic-ref --short -q HEAD)):master --force
like image 22
Martin Moss Avatar answered Sep 18 '22 17:09

Martin Moss