Git Worktree for SSR/ Angular Universal deploy on Heroku

Vijay Goel, MD
Building the Stack
Published in
1 min readFeb 1, 2018

Update: Managing branch merges using worktree appears to have run it’s course. It works but it’s pretty messy and fragile. I’m moving toward using workspaces in Angular 6 to separate the project (and I loved the xplat concept discussed at ng-conf…will try it when it’s ssr-ready)

Was scratching my head at how to create a parallel version of my code to enable quick deployment of Angular Universal SSR on heroku while maintaining my master version without all the SSR modifications to make heroku work.

In heroku for instance, most of the devDependencies need to be moved into dependencies. And then there’s a lot of work to separate window and document elements into if statements relevant to server and browser versions.

Stumbled on Git Worktree as a way to maintain multiple parallel branches while hopefully keep from shooting myself in the foot hard and irreversibly.

So now I can create separate “worktrees” under app/main and app/ssr, lock those separate trees to keep from accidentally deleting, keep parallel git log histories which enables reversal of mistakes (I want my merges to only go in one direction from main => ssr so I maintain the separate ssr modifications).

Crossing fingers and hoping this ends up being an easy to maintain solution to keeping parallel versions in (slightly modified) sync.

--

--

Vijay Goel, MD
Building the Stack

Improving operations via technology and structured thinking (current focus chefs and catering)