Force choosing whether to squash or not when merging PR #208316
Replies: 2 comments
|
💬 Your Product Feedback Has Been Submitted 🎉 Thank you for taking the time to share your insights with us! Your feedback is invaluable as we build a better GitHub experience for all our users. Here's what you can expect moving forward ⏩
Where to look to see what's shipping 👀
What you can do in the meantime 💻
As a member of the GitHub community, your participation is essential. While we can't promise that every suggestion will be implemented, we want to emphasize that your feedback is instrumental in guiding our decisions and priorities. Thank you once again for your contribution to making GitHub even better! We're grateful for your ongoing support and collaboration in shaping the future of our platform. ⭐ |
|
@alexsapps That's a very relatable problem! Accidental squash merges on clean commit histories (or accidental merge commits on messy PRs) are tricky to undo once branch protection rules kick in. While GitHub doesn't currently offer a setting to "force explicit selection on every PR merge button," here are two workarounds teams use to enforce or safeguard merge strategies: Workaround 1: Enforce Merge Strategy via GitHub Actions Check RunYou can add a GitHub Actions workflow that inspects PR labels or PR title/body keywords to fail a required status check if the wrong merge strategy is used or if a label isn't explicitly applied:
Workaround 2: Repository-Level Merge Defaults & Branch Protection RulesIf you maintain different repos for different workflow types, repo administrators can restrict allowed merge methods under Settings → General → Pull Requests:
Adding your upvote to similar Product Feedback threads around "PR Merge Strategy Enforcer Rules" is the best way to help GitHub product managers prioritize this feature! |
Uh oh!
There was an error while loading. Please reload this page.
🏷️ Discussion Type
Product Feedback
Body
Sometimes I'm not paying attention when I click the merge button, and end up merging with whatever option I chose last time (merge or squash-merge). It's hard to undo because of branch protection on the main branch, and the wrong choice either clutters the history or causes history to be lost. I do my best to be careful but I just can't remember every time, especially after reviewing a bunch of complicated code.
I wish there was an option to require selecting normal merge (or rebase), or "squash" merge each time a PR is merged to prevent this.
I don't want to try to standardize on one or the other in my workflow. It would be difficult to try to make all PRs with the intent to merge them without squashing (working with messy commits from volunteers, or dealing with lots of fixes from code review) and likewise would also be sad to try to always squash, even when the commits are clean and provide a useful history.
All reactions