Search code examples
githerokugit-submodulesgit-subtree

How to deploy only part of project to Heroku?


I am building a project that consists of two folders: one to be run on an IOT device and the other to run on the server. The server part is to be deployed on Heroku. I'd like to keep the project in one overall Git project though, so that I can keep it all organised together.

/* current setup */
├── server/
├── device/
└── .git/

However to deploy a project to Heroku means that the server's package.json has to be in the root, which breaks the symmetry of the project. I also just don't want the server to be burdened with the device's files.

Thus I think the best thing would be to have a separate Git subfolder for the server to push to Heroku. What would the the most suitable way of having a sub-thing for this purpose? I've read about submodules and subtrees but am finding it hard to figure out what exactly the strengths and weaknesses are for this use case.


Solution

  • After a lot of reading and comparing between what looked like the two relevant options - submodules and subtrees - I settled on subtrees.

    Subtrees allow me to do exactly what I want, namely push a subfolder of my project to Heroku.

    The documentation (which can be found here) isn't amazing, but sufficient to make sense out of.