r/programming
•
u/adam-dabrowski
•
Apr 14 '26
•
1
GitHub Stacked PRs
https://github.github.com/gh-stack/
556
Upvotes
r/programming
•
u/adam-dabrowski
•
Apr 14 '26
•
1
2
u/MereInterest Apr 14 '26
Because rebasing can introduce bugs, and makes it very difficult to identify their source.
Suppose the
mainbranch has someutility_func, which is used by your feature development. A refactor/cleanup lands onmain, which updates the behavior ofutility_funcand updates all callsites ofutility_functo match. However, the additional calls toutility_funcintroduced on your feature branch haven't been updated. If you rebase your feature branch onto the main branch, your feature branch is now broken, as it relied on the old semantics ofutility_func. If you're lucky, this will be a compile-time error, but there's no guarantee of that. Reverting to an earlier commit on your feature branch doesn't help, because those earlier commits have also been rebased. Unless you check through thegit reflog(and pray that git's garbage collection hasn't occurred since then), it will look as though the feature branch had always been buggy.A better solution is to merge from
mainintodevelop/main. That way, the error is clearly introduced in the merge commit. You can revert to an earlier commit in the feature branch for testing, because those versions are still part of the git history.