I am trying to find a tool that would help disable squash and merge for certain branches, but not all of them.
Github settings is allowing me to disable squash and merge, but it applies for all the branches, and the protected branches area does not have an option to limit merge options.
Thank you!
No, GitHub doesn't let you restrict who can perform a merge. However, if you want to require a specific group of people to approve a PR before merging, use the CODEOWNERS file and require an approval from a code owner before merging in the branch protection settings.
On GitHub.com, navigate to the main page of the repository. Under your repository name, click Settings. Under "Pull Requests", select Allow squash merging. This allows contributors to merge a pull request by squashing all commits into a single commit.
Enabling Commit Squashing by Default To enable commit squashing as the default option in your repository: Navigate to your chosen repository and open the Settings sub-tab. Open the General Settings page. Check the box for Squash commits on merge default enabled.
Using GitHub's settings, you can only block merging by requiring either pull request reviews, status checks to pass, signed commits or linear history as shown under the branch protection settings. Apart from the above, there is no other way currently to block self merging PRs on GitHub.
But GitHub also provides us several merge options and “Squash and merge” option is one of them. Because a squash-merged commit is not the same as the commits in a local branch, git cannot list the squash-merged local branch by git branch --merged.
NOTE: If your project is set to Do not allow Squash and Merge, the users still have the option to squash commits locally through the command line and force-push to their remote branch before merging. Squash Commit Options is under development but ready for production use.
This bothers me for one simple reason: a squash and merge default means a history destruction default [1]. The whole point of commit squashing is to destroy history. Sometimes that's fine - for example, I might squash a typo fix into an earlier commit, because who cares that I typo'd vare instead of var?
We can detect squash-merged branch with git merge-base, git commit-tree, and git cherry. Thus we can remove all outdated local branches even we use the “Squash and merge” method on GitHub.
No, to the best of my knowledge, that's not possible with GitHub. You could create a feature request for them and they might implement it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With