Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to disable squash and merge for certain branches in GitHub

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!

like image 873
paxcow Avatar asked Jan 26 '21 08:01

paxcow


People also ask

How do I restrict Git merge?

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.

How do I enforce squash and merge in GitHub?

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.

How do you only merge squash?

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.

How do I block a merge in GitHub?

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.

Is there a way to squash and merge in 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.

Can I squash a commit and force push to another branch?

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.

What does a squash and merge default mean?

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?

How to detect squash-merged branch in Git?

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.


Video Answer


1 Answers

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.

like image 102
knittl Avatar answered Nov 10 '22 13:11

knittl