GitHub disallow merge and rebase commits for multiple repositories - Stack Overflow

时间: 2025-01-06 admin 业界

This is a similar question to github "Automatically delete head branches" for multiple repositories. In that case, the gh command can be used in a loop to configure the option across multiple repos. The gh cli has these options for the repo edit subcommand:

--enable-merge-commit      Enable merging pull requests via merge commit
--enable-rebase-merge      Enable merging pull requests via rebase
--enable-squash-merge      Enable merging pull requests via squashed commit

Is it possible to disallow merge-commit and rebase-merge programmatically? Or to put it another way, is it possible to only allow squash-merge?

REST API (or other API) would also be acceptable.

This is a similar question to github "Automatically delete head branches" for multiple repositories. In that case, the gh command can be used in a loop to configure the option across multiple repos. The gh cli has these options for the repo edit subcommand:

--enable-merge-commit      Enable merging pull requests via merge commit
--enable-rebase-merge      Enable merging pull requests via rebase
--enable-squash-merge      Enable merging pull requests via squashed commit

Is it possible to disallow merge-commit and rebase-merge programmatically? Or to put it another way, is it possible to only allow squash-merge?

REST API (or other API) would also be acceptable.

Share Improve this question asked yesterday davejagodadavejagoda 2,5281 gold badge21 silver badges29 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

When in doubt, RTFM: https://cli.github.com/manual/gh_repo_edit

gh repo edit <username>/<reponame> \
    --enable-merge-commit=false \
    --enable-rebase-merge=false \
    --enable-squash-merge=true

The =true on the last line is optional but included to be more specific.