Skip to content

pr-branch-non-default

Included in configs: ✅ recommended, 🔒 strict

Sending a PR from a repository’s default branch, commonly main, means that repository will have a hard time pulling in updates from the upstream repository. It’s generally recommended to instead create a new branch per pull request.

Two terms are useful to know when working with forked repositories and pull requests:

  • “Base”: The main repository that receives the pull request.
    • Your local Git clone likely refers to this as “upstream”.
  • “Head”: Your fork that is sending the pull request.
    • Your local Git clone likely refers to this as “origin”.

GitHub does not provide a way to change the head branch of a pull request. You’ll want to:

  1. Create a new branch on the head repository
  2. Close the original pull request on GitHub
  3. Send a new pull request from that branch

PR sent from a default main branch:

github-actions
👋 Hi @YourUsername, thanks for the issue! A scan flagged a concern with it. Could you please take a look?

[pr-branch-non-default]

This PR is sent from the head repository’s default branch. Sending a PR from a default branch means the head repository can’t easily be updated after the PR is merged. Sending a PR from a repository’s default branch, commonly main, means that repository will have a hard time pulling in updates from the upstream repository. It’s generally recommended to instead create a new branch per pull request. You’ll need to:

  1. Create a new branch on your fork
  2. Send a new pull request from that branch
  3. Close this pull request

Each snippet in this section shows changes to the full .github/workflows/octoguide.yml workflow from Get Started.

This rule is enabled by default as part of the recommended config.

To use this rule on its own, enable it in rules with the none config:

.github/workflows/octoguide.yml
jobs:
octoguide:
runs-on: ubuntu-latest
steps:
- uses: OctoGuide/bot@0.26.4
with:
config: none
github-token: ${{ secrets.GITHUB_TOKEN }}
rules: |
{
"pr-branch-non-default": true
}