github

GitHub disallow merge and rebase commits for multiple repositories


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.


Solution

  • 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.