Skip to content

Instantly share code, notes, and snippets.

@cubuspl42
Last active April 24, 2023 09:53
Show Gist options
  • Save cubuspl42/a5d75d92198acd6c08c4adbd0e848b79 to your computer and use it in GitHub Desktop.
Save cubuspl42/a5d75d92198acd6c08c4adbd0e848b79 to your computer and use it in GitHub Desktop.
Sensible GitHub repository configuration

Highly opinionated. This works for my use cases. Some parts assume that GitHub Actions are used.

General

Pull Requests

image

  • Ensure "Allow merge commits" is unchecked
  • Ensure "Allow squash commits" is unchecked
  • Ensure "Allow rebase commits is checked
  • Ensure "Always suggest updating pull request branches" is checked
  • Ensure "Allow auto-merge" is checked
  • Ensure "Automatically delete head branches" is checked

Branches

Protection rule for main

image

Ensure there's a branch protection rule for main. Press "Add branch protection rule" if there's none.

  • Ensure "Branch name pattern" is "main"
  • Ensure "Require approvals" is unchecked
    • This works well for one person projects or small teams with a high trust level
  • Ensure "Require status checks to pass before merging" is checked
    • Ensure "Require branches to be up to date before merging" is checked
    • Search for appropriate status check(s), for example: build or test. This assumes that the GitHub Actions workflow is alread pushed to the repository and was run at least once.
  • Ensure "Require linear history" is checked

Remember to press "Create" or "Save changes"!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment