DreamStack's Git Flow Hybrid Strategy
This guide will provide you with a step-by-step breakdown of our approach to version control, emphasizing the practices we value most.
Although not the same on all projects, we roughly follow this setup as a general framework. This guide will provide you with a step-by-step breakdown of our approach to version control management, emphasizing the practices we value most.
1. Understanding Our Branching Model
- Main Branch: Represents the production-ready state of our projects.
- Develop Branch: A branch where features, enhancements, and other changes meant for the next release are integrated.
- Weekly Release Branch: Cut from the
develop
branch weekly. It's the branch we prepare for production release.
2. Setting Up Conventional Commits with Commitizen (cz)
Using Commitizen, we enforce conventional commit messages, which aids in version management and changelog generation.
Steps:
- Install Commitizen globally:
- Use
git cz
instead ofgit commit
when committing changes. - Follow the prompts to craft a conventional commit message.
3. Effective Branch Naming
To ensure clarity and consistency, always name branches descriptively. For features, use feature/your-feature-name
. For bugs, bugfix/your-bugfix-description
, and so on.
4. Auto-generating Changelogs
With conventional commits in place, we use tools like semantic-release to auto-generate changelogs and bump versions based on commit messages.
5. The Power of Rebasing & Squashing Commits
Why Rebase?
- Clean History: Rebasing allows us to maintain a linear commit history, making it easier to follow the project's evolution.
- Resolve Conflicts Once: If there are conflicts between the branches, rebasing requires you to resolve the conflict once, after which the rest of the patches apply cleanly.
Why Squash?
- Focused Commits: Squashing combines multiple commit messages into one, providing a concise history.
- Easier Reviews: Fewer commits mean easier code reviews.
Steps:
- Before merging your feature branch into
develop
, ensure you squash your commits: - Follow the instructions to squash your commits.
6. The Nightmare of Long-Running PRs
Long-running PRs can be challenging due to:
- Merge Conflicts: The longer a PR is open, the higher the chance that changes in the
develop
ormain
branch will conflict with the PR's changes. - Drifting Away from Main Codebase: As the main code evolves, the PR can become outdated, leading to potential integration issues.
Tips:
- Regularly Rebase: Regularly rebase your feature branch against the branch you intend to merge with (usually
develop
). - Smaller, Focused PRs: Instead of one large PR, break it down into smaller, more focused PRs.
Conclusion
At DreamStack, our Git Flow Hybrid Strategy is at the core of ensuring smooth and efficient release management. Embracing this strategy, coupled with the tools and practices outlined, will not only improve the quality of your contributions but also enhance our collective productivity. Welcome aboard, and happy coding! 🚀