neverfox
neverfox

Reputation: 7010

How to keep a deployment repo for Heroku within a development Git repo and keep them separate?

I have a git repo that I've used to develop out my app and now I want to deploy to Heroku. However I don't want to deploy this repo itself but rather a build of the code in this repo. My build system creates a dist directory within my repo directory that contains everything necessary for deployment anywhere. It is set up to be ignored in .gitignore because it's not necessary to store it as it can be rebuilt any time and would be redundant. However, Heroku needs a git repo for deployment. I could manually copy the output in dist to some other repo I keep around just for Heroku but that seems really ugly. I want to be able to develop source, build deployment code, and the push the former to GitHub/Lab and the latter to Heroku without overlap.

What I'd like is something like this: My dist folder is its own git repo, to satisfy Heroku, that isn't included in the parent dev repo's history, i.e. when I push my dev repo to GitHub or GitLab, the dist folder is ignored. When I push the contents of dist to Heroku, it has no knowledge of the fact that it's contained within a development project. This way my build process automatically changes my deployment repo, which I can make commits to when necessary to mark deployment events.

What I'm not sure about is how to set this up, if it's possible. I've heard horrible things about submodules and I'm not even sure that's the right tool for the job, as it seems to relate more to including other outside repos within mine. Here I want to create a repo that live only within my parent repo.

If there are others with a similar setup that know of something better than what I've asked for, I'm open to ideas.

Upvotes: 4

Views: 1051

Answers (1)

stephenmurdoch
stephenmurdoch

Reputation: 34613

I would create another branch called 'dist':

git checkout -b 'dist'

And inside that branch I would alter the gitignore file so that the 'dist' folder is included.

I'd then push my dist branch to heroku like so:

git push heroku dist:master

Does that work for you?

Upvotes: 4

Related Questions