Main Branch Stability with Fast-Moving Features #177985
-
Discussion TypeQuestion Discussion ContentProblem Body Let’s say I have a team that uses GitHub with Fast-Forward Merge only policy for all PRs into master. A developer develops on a long living feature branch feature/massive-refactor for two weeks. These 100+ smaller, stable changes get merged into main while working on this. The developer frequently rebase their feature branch onto the newest main in order to remain updated. The heart of the problem: Silent conflict and a cut history The Failed Merge: The last rebase looks good locally. The developer opens the PR and Squashes their commits (to cleanup history) at the time the PR is merged. result: The net result ends up being that we are breaking the build/tests on main right after this merged commit lands. The Dilemma of the Recovery: The team now confronts a tricky recovery situation: Option 1: Revert Since the big, squashed merge is all but unaware of the history it came from, reverting it would be quite difficult and incurs a loss of the entire refactoring history up to this point as that work must also be done over again. The issue with the root cause is that the Fast-Forward/Rebase method prioritizes clean history at the cost of safety in merging and traceability. That single squash commit that was committed to main is now difficult to isolate and revert. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
The resolution is a philosophical shift from liking only clean, linear history to liking branch stability and easy rollback. Step 1: Alter the Merge Strategy (Use Merge Commits)Instead of forcing Fast-Forward or Squash, the team can employ Standard Merge Commits (or a local "Rebase-and-Merge" convention with a single merge commit). This creates a non-linear but recoverable history with a Merge Commit M linking the feature branch to main's history M1 and M2. Why it works: A merge commit can safely be reverted using
then push the revert: This process maintains the stability of main while providing a clean, fast way to undo complex changes. |
Beta Was this translation helpful? Give feedback.
The resolution is a philosophical shift from liking only clean, linear history to liking branch stability and easy rollback.
Step 1: Alter the Merge Strategy (Use Merge Commits)Instead of forcing Fast-Forward or Squash, the team can employ Standard Merge Commits (or a local "Rebase-and-Merge" convention with a single merge commit). This creates a non-linear but recoverable history with a Merge Commit M linking the feature branch to main's history M1 and M2. Why it works: A merge commit can safely be reverted using
git revert -m 1 <merge-commit-sha>This successfully undoes all the modifications out of the feature branch without affecting subsequent commits to main and without destroying t…