Skip to content

gh pr merge --delete-local for PR reviews #7355

@scarf005

Description

@scarf005

Describe the feature or problem you’d like to solve

I've been reviewing many PRs recently, and the workflow is typically:

gh pr checkout <PR number>
gh pr merge <PR number>
git switch main
git branch -D <PR name>
git pull

I tried using gh pr merge -d

gh pr checkout <PR number>
gh pr merge -d <PR number>

as it automatically

  1. deletes local and remote branches
  2. switches to default branch
  3. pulls the merged commit

but it does not work due to reasons mentioned in #2860.

Proposed solution

almost every time when i review a PR from other's fork,

  1. i want to keep their remote branch (as it's theirs)
  2. but i want to delete the local PR branch i've gh pr checkouted (to keep my local branches clean), then switch to main and pull the changes.

a new flag, --delete-local could address this issue. after the feature gets added, my workflow would look like:

gh pr checkout <PR number>
gh pr merge --delete-local <PR number>

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementa request to improve CLIhelp wantedContributions welcome

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions