#TIL 18 - Deploy to heroku from sub directory | ProductsWay

#TIL 18 - Deploy to heroku from sub directory

Sep 26, 2021 · Dung Huynh

What

Deploy a subdirectory (e.g., server/) from a monorepo to Heroku.

Why

Heroku's buildpack expects the app at the repository root. git subtree push --prefix server creates a synthetic commit containing only that folder's history, so Heroku sees a standalone app without restructuring your repo.

How

Add Heroku remote:

heroku git:remote -a your-app-name

Deploy subdirectory:

git subtree push --prefix server heroku main