Skip to content

Hammock thoughts

Git your plan together

domain driven frontend, Lessons from the road2 min read

As they say "weeks of coding can save hours of planning", and unfortunately I experienced this quite early in the process. We recently moved to a git flow based on rebasing. We have two main branches - master and staging, and each represent one of the two environments. When we take a new task we branch out of staging, work on the branch, rebase from staging, merge, and once a day we deploy to production - merging from staging into master.

Quick a simple flow which generally works fine. When we have larger tasks we might create a feature task, then each subtask follows a similar flow, just using the feature branch as a out base. Again, a simple and clear flow that should work, except when you mess it up.

So how can you mess it up? I'm sure there are many option but here's how I did it. We started working on the refactor, working on two major changes simultaneously. As far as I remember, one feature (Feature A) used a feature branch as two of us worked on it. The other feature (Feature B) simply was on one branch as just one developer was working on it. As Feature B started making progress the developer started merging into staging incremental changes.

So far so good :)

But then... I started thinking too much (which usually isn't a good sign) and started dreading the rebase. For some reason I thought that if we rebase now staging into our feature branch it would make thing much simpler in the long run. And boy was I wrong.

All the tasks touched and changed a ton of files as we were refactoring the system. Just for a bit of feel, Feature A was a restructuring the folder structure while Feature B was fixing the app layout, two very large changes. In any case, what the rebase entailed was now any minor task had to perform the whole rebase again. As all of the changes were included in the feature branch, when one of us wanted to merge into the feature branch, we would rebase it into our branch. However, there were so many changes there now the huge dreaded rebase was performed multiple times. We could have stuck to the plan and made one large rebase, but instead we performed an almost as large rebase again and again.

So, when making major changes I suggest to plan you git flow as well. And I heard that even more importantly, once you have a plan stick to it. Good Luck!

© 2022 by Hammock thoughts. All rights reserved.
Theme by LekoArts