0

I have a Git repository which contains multiple subdirectories. One of the subdirectory is the dist folder which I'd like to deploy to Heroku. I do not want to deploy the whole source code to Heroku as it seems unneeded plus there are documents like readme files which are def. not needed on there.

I found this thread: How can I deploy/push only a subdirectory of my git repo to Heroku?

but I failed to find any more information about the subtree command which makes me believe that it never made it way into the git core and is not the state of the art to handle such a task.

Basically:

I have a git repository in Gitlab -- Containing a folder named dist/. I'd like to git push the folder dist/ to a different remote (Heroku git) -- What am I searching for?

Thanks in advance.

2 Answers2

1

To split your branch,

git subtree split --branch heroku --prefix dist/

heroku is new destination branch (and) dist/ is original directory.

This will create a new branch or update existing branch called heroku


You can view this branch using git checkout heroku.

If you need to push heroku branch to your repository's master branch,

git push heroku HEAD:master

(You need to add heroku as your remote branch before using this command. If you have your heroku branch as your origin, you can replace heroku to origin or leave it out as origin is the default branch git pushes to.


If you need to update heroku branch after updating it from master, you need to checkout master and repeat the process of spiting your branch. After re-splitting, you can push your updated branch.

As far as I've tested, this copies your commit log as well so you won't have to worry about your log.

deepjungle
  • 128
  • 8
  • If I check out the branch Heroku shouldn't there only be the CONTENT of the dist folder? The Heroku branch contains the contents of the dist folder as well as the dist and src folder... :^) edit: I had to check out the heroku branch and perform a git reset / git clean for it to work... – youngStupidQuestionGod Feb 06 '18 at 12:09
0

The best way to deploy a repository with a node.js server in a subdirectory:

  1. Copy package.json from server directory to root directory
  2. Change “node server.js” to “node subdirectory/server.js”
  3. Choose your repo in Heroku/Deploy to deploy and use.