I’m pretty new to Git, GitHub, and Heroku deployment. Coming from SVN, I’m still figuring out the best workflow patterns.
My current setup:
I forked a private GitHub repository that has this structure:
/main-project
/applications
/team-a-apps
/web-app-alpha
...files...
/web-app-beta
...files...
/team-b-apps
/mobile-app-one
...files...
/mobile-app-two
...files...
/shared-plugins
...files...
Each application folder contains a separate Rails application. I’ve created individual Heroku apps for each one, and each Heroku app is its own git repository where I deploy my code.
The challenge:
I want to keep my GitHub fork updated automatically whenever I push changes to Heroku. Right now I have to manually sync changes between the two repositories.
The main issue is that Heroku treats each app as a standalone git repo, but on GitHub these apps are just subdirectories within the larger project repository.
I’ve heard about git submodules but I’m not sure if that’s the right approach here. What’s the best way to maintain this dual repository setup? Any advice would be really helpful.
Been there with the SVN to Git transition - totally get the confusion. I created a simple shell script that handles dual pushes automatically. After making changes in your GitHub fork, the script copies each app directory to its respective Heroku git repo and pushes both at once. So /applications/team-a-apps/web-app-alpha gets copied to your heroku-alpha repo, then pushed to both GitHub and Heroku remotes. Your GitHub fork stays as the single source of truth while you keep separate Heroku deployments. Treat GitHub as master and Heroku repos as deployment targets only. Way simpler than submodules or complex CI/CD when you’re starting out.
git subtree is a good fit for this. It lets u push specific directories to their own repos, great for Heroku. Try git subtree push --prefix=applications/team-a-apps/web-app-alpha heroku-alpha-remote master to keep things in sync easier.
I’ve hit this same issue with monorepos and Heroku. Skip git subtree - it’s a pain. Set up GitHub Actions instead. Create workflows that watch specific folders and auto-deploy to the right Heroku app when they change. Your GitHub fork stays the main repo, but you get separate Heroku deployments. The workflow spots which folder changed, grabs that code, and pushes it to the right Heroku remote. Way cleaner than juggling multiple git workflows manually.