This git strategy focuses on maintaining stability and coherence in larger teams or open-source projects where versioning is crucial. Here's the gist of the idea: Create a pre-release branch: Instead of merging feature branches directly into main, create a pre-release branch (e.g., v2.0.0-pre-release) from main. Merge feature branches into pre-release: All development work (features, bug fixes) is merged into this pre-release branch. This allows developers to use normal git workflows (commit, push) on their individual branches. Continuous integration on pre-release: Run CI/CD pipelines against the pre-release branch. This ensures all new changes are tested together, simulating a real, fully-featured build. QA and testing: Use the pre-release branch for QA, acceptance testing, and user acceptance testing (UAT). This provides a more realistic testing environment with all features integrated. Merge request process: Instead of creating pull requests directly to main, developers create merge requests to the pre-release branch. This acts as a "squash for PRs," consolidating changes before they reach main. Finalize release: Once the pre-release branch is deemed ready (containing one or more completed features or fixes), merge it into main. Create version tag: After merging to main, create a version tag (e.g., v2.0.0) to mark the release point. Benefits of this approach: Maintains a stable main branch Allows for integrated testing of multiple features Provides a clear pre-release phase for thorough testing Simplifies version management with coherent tags Enables easier tracking of what changes are included in each release Facilitates writing comprehensive release notes This strategy emphasizes collaboration and integration testing, ensuring that all components work together before reaching the main branch. It's particularly suited for projects where stability and version control are paramount.
-
-
Save Attumm/2fda8723caa0ba3d42f2d0cffadf31fa to your computer and use it in GitHub Desktop.
Document: Explanation of a Pre-Release Git Workflow: Branch-Level "Squash" for Stability
This document explains a Git workflow that uses a pre-release branch to achieve a form of "squash merging" at the branch level. This approach enhances release stability and simplifies change management, especially in team environments. It outlines how this workflow acts like a "git squash" but for entire branches, consolidating features before they become part of the main release.
This workflow is designed around the idea of a "branch-level squash," similar in principle to how git squash commit works for individual commits. It creates a consolidated and clean integration point before release:
-
The
mainBranch: Clean, "Squashed" Release History: Themainbranch is like your final, polished release – it holds the official, released software in a clean and linear history, much like a branch with well-squashed commits. It's kept stable and reliable for users, benefiting from this "squashed" and consolidated history. -
Creating a Pre-Release Branch (
vX.Y.Z-pre-release): The "Squashing" Area: Before each release, a "pre-release branch" (e.g.,v2.0.0-pre-release) is created frommain. Think of this branch as the area where we "squash" together all the feature branches. It's a staging area for the upcoming release, named with a version number and "-pre-release" to organize and define its purpose. -
Feature Branches (
feat/new-feature): Individual Contributions: Developers work in separate "feature branches" to develop features or fixes. These branches might have many commits, representing the detailed development process of each feature. -
Merging to Pre-Release: "Squashing" Feature Branches: Completed feature branches are merged into the
pre-releasebranch using merge requests. Crucially, these merge requests to thepre-releasebranch act as a form of "squash for branches." Just likegit squash commitconsolidates multiple commits into a single, cleaner commit, merging feature branches intopre-releaseconsolidates potentially many commits of a feature into the pre-release branch, ready for integrated testing and a cleaner release. -
Testing on Pre-Release (CI/CD and QA): Validating the "Squashed" Integration: The
pre-releasebranch, now containing the "squashed" integrations of features, is rigorously tested. CI/CD and QA processes ensure that these integrated, "squashed" features work well together and are release-ready. -
Finalizing Pre-Release: Ready for
main- The Final "Squash" Destination: After testing confirms stability, thepre-releasebranch, with all its "squashed" feature integrations, is ready to be merged intomain. -
Merging to
main: Creating the "Squashed" Release: The validatedpre-releasebranch is merged into themainbranch. This merge operation takes the "squashed" and tested changes frompre-releaseand makes them the new, official release onmain. -
Version Tag (
vX.Y.Z): Marking the "Squashed" Release Point: A "version tag" is created onmainto mark the specific commit that represents this "squashed," consolidated, and official release.
In Simple Terms: Develop features in separate branches → "Squash" merge features into a pre-release branch (like a branch-level git squash) → Test the "squashed" changes in pre-release → If tests pass, merge the "squashed" pre-release to main for the final, clean release.
This Git strategy, using the pre-release branch as a "branch-level squash" mechanism, offers these key benefits:
-
mainBranch with Clean, "Squashed" History: Themainbranch maintains a cleaner, more linear history, as features are integrated in a consolidated way via thepre-releasebranch. This "squashed" history onmainimproves readability and simplifies tools likegit bisect. -
Consolidated Feature Testing (Integration "Squashing"): The
pre-releasebranch acts as the central point for consolidating and testing all features together. This "squashing" of features into thepre-releasebranch ensures comprehensive integration testing before release, catching issues early. -
Clear, "Squashed" Release Units: Releases on
main, resulting from merging thepre-releasebranch, represent well-defined and "squashed" units of change. Each release is a consolidated package of features that have been tested together in thepre-releasestage. -
Simplified Rollbacks and Version Tracking (Clean "Squash" History): The cleaner, more linear, and "squashed" history on
main, along with version tags, simplifies version tracking and makes rollbacks to previous releases more straightforward and less error-prone. -
Improved Traceability and Release Notes (Consolidated "Squash" View): The
pre-releasebranch provides a clear, consolidated view of all changes going into a release (the "squashed" features). This simplifies understanding release content and writing accurate release notes.
In Summary: This strategy utilizes a pre-release branch to achieve a "branch-level squash" effect, consolidating feature changes before they reach the main release branch. This "squashing" action results in a cleaner project history, improved integration testing, and more reliable and manageable software releases, especially beneficial for collaborative projects.
Is this explanation, highlighting the "branch-level squash" analogy, now closer to what you were aiming for and more insightful? Please let me know your thoughts.
This system allows also for upgrading for instance.
One would start with patch
v2.0.1
During development it becomes clear that it's actually a minor
v2.1.0
Since both go from the main, one can simply create that branch and merge v2.0.1 into that one instead of main.