Examples

Show Version

ghprmerge --version

Rebase Run

Update out-of-date branches without merging:

ghprmerge --org myorg rebase --source-branch dependabot/

For Dependabot branches, this posts a @dependabot rebase comment. For other branches, it uses GitHub’s update branch API.

Note: merge and rebase are separate subcommands and cannot be combined. After rebasing, wait for checks to pass then run merge.

Merge Run

Merge PRs that are already in a valid state (up-to-date, checks passing):

ghprmerge --org myorg merge --source-branch dependabot/

PRs that are behind the default branch will be skipped (use rebase first to update them, or --skip-rebase to merge anyway).

PRs with no checks configured are allowed to merge. PRs with pending checks are still skipped.

Merge with Skip Rebase

Merge PRs even when they are behind the default branch:

ghprmerge --org myorg merge --source-branch dependabot/ --skip-rebase

This is useful when your repository is configured to not require branches to be up-to-date before merging. The --skip-rebase flag allows merging without first updating the branch.

Note: --skip-rebase is only available under the merge subcommand. PRs with merge conflicts or failing checks will still be skipped.

Confirmation Mode

Scan all repositories first, then prompt before taking actions:

ghprmerge --org myorg rebase --source-branch dependabot/ --confirm

Use --confirm with either merge or rebase to preview planned actions before execution. Pending actions are listed, and on confirmation, execution progress is shown with a progress bar.

ghprmerge --org myorg merge --source-branch dependabot/ --confirm

Verbose Output

Stream repository decisions as each repository is scanned, including repositories with no matching pull requests:

ghprmerge --org myorg --verbose merge --source-branch dependabot/

By default, the scan stays quiet apart from the progress bar and only repositories with matching PRs are displayed after the scan completes.

Verbose Confirmation Mode

Stream scan-time decisions, then clear them before showing the actions that were actually performed:

ghprmerge --org myorg --verbose merge --source-branch dependabot/ --confirm

This is useful when you want live visibility during the scan without leaving the terminal full of pending entries after you confirm.

Disable Colored Output

Disable ANSI color codes for piping or CI:

ghprmerge --org myorg --no-color merge --source-branch dependabot/

Scoped Repository Run

Only process specific repositories:

ghprmerge --org myorg --repo repo1 --repo repo2 merge --source-branch dependabot/

Multiple Source Branches

Match PRs from multiple source branch patterns in a single pass:

# Merge PRs matching either dependabot/ or repver/ patterns in a single pass
ghprmerge --org myorg merge --source-branch dependabot/ --source-branch repver/

Specifying multiple --source-branch flags scans all repositories once and matches PRs against each pattern. This reduces the number of scanning passes compared to running separate commands for each pattern. When multiple patterns match PRs in the same repository, the first matching pattern per repository takes priority for concurrent PR handling.

Multiple source branches also work with the rebase subcommand:

ghprmerge --org myorg rebase --source-branch dependabot/ --source-branch repver/

Dependabot Focused Run

Match only Dependabot npm updates:

ghprmerge --org myorg merge --source-branch dependabot/npm_and_yarn/

Match only Go module updates:

ghprmerge --org myorg merge --source-branch dependabot/go_modules/

Limited Run

Process at most 10 repositories:

ghprmerge --org myorg --repo-limit 10 merge --source-branch dependabot/

JSON Output for Scripting

Get structured output for automation:

ghprmerge --org myorg --json merge --source-branch dependabot/ | jq '.summary'

Pipe to other tools:

ghprmerge --org myorg --json merge --source-branch dependabot/ | \
  jq -r '.repositories[].pull_requests[] | select(.action == "would merge") | .url'

Report Mode

Scan open PRs across the organization and group them by source branch name:

ghprmerge --org myorg report

Filter to specific branch prefixes:

ghprmerge --org myorg report --source-branch-prefix dependabot/,repver/

Require at least 3 PRs in a group:

ghprmerge --org myorg report --min-group-size 3

Get JSON output for scripting:

ghprmerge --org myorg --json report

Show only branch names and counts:

ghprmerge --org myorg report --verbosity brief

Include PR titles in the output:

ghprmerge --org myorg report --verbosity verbose

Scope the report to specific repositories:

ghprmerge --org myorg report --repo repo1 --repo repo2

Using Environment Variables

export GITHUB_TOKEN=ghp_xxxxxxxxxxxx
export GITHUB_ORG=myorg

ghprmerge merge --source-branch dependabot/

Complete Production Workflow

# Set authentication
export GITHUB_TOKEN=ghp_xxxxxxxxxxxx

# Step 1: Rebase out-of-date branches with confirmation
ghprmerge --org myorg rebase --source-branch dependabot/ --confirm

# Step 2: Wait for checks to complete (manual or scripted)
sleep 300

# Step 3: Merge ready PRs
ghprmerge --org myorg merge --source-branch dependabot/

CI/CD Usage

Example GitHub Actions workflow:

name: Auto-merge Dependabot
on:
  schedule:
    - cron: '0 9 * * 1'  # Every Monday at 9am
  workflow_dispatch:

jobs:
  merge:
    runs-on: ubuntu-latest
    steps:
      - name: Download ghprmerge
        run: |
          curl -L https://github.com/UnitVectorY-Labs/ghprmerge/releases/latest/download/ghprmerge_linux_amd64 -o ghprmerge
          chmod +x ghprmerge

      - name: Check version
        run: ./ghprmerge --version

      - name: Merge ready PRs
        env:
          GITHUB_TOKEN: $
        run: ./ghprmerge --org myorg --repo-limit 20 merge --source-branch dependabot/