Repository navigation
Add a gh pr update command corresponding to the API call / button on the Web UI #8426
Description
Activity
- addeddiscussFeature changes that require discussion primarily among the GitHub CLI teamFeature changes that require discussion primarily among the GitHub CLI team
on Dec 6, 2023 And a benefit of it doing it using the GH API instead of locally is that when you do it in the GH UI, it doesn't clear your approvals, whereas if you update the branch locally and push, I'm pretty sure it does.
Hey @tgoodsell-tempus, thanks for opening this and sorry about the slow response, December was a busy time and then we were into the holidays. We're catching up on untriaged issues at the moment.
I think some of the behaviour you're describing can be emulated with
gh repo syncbut I can definitely see why it would be natural to find an equivalent to the UI undergh pras a first classprbehaviour.The REST API equivalent to the GQL mutation would appear to be https://docs.github.com/en/rest/pulls/pulls?apiVersion=2022-11-28#update-a-pull-request-branch.
We're a bit hesitant to make changes around
gh prat the moment because there's so many issues and it might be that the whole command needs a bit of a redesign. On the other hand, this one feels fairly straightforward and self-contained so maybe we'll open it up to community contributions. I'll discuss with the team!And a benefit of it doing it using the GH API instead of locally is that when you do it in the GH UI, it doesn't clear your approvals, whereas if you update the branch locally and push, I'm pretty sure it does.
@maco : it is a little nuanced as it depends on how you setup branch protection rules and/or repository rulesets
Dismiss stale pull request approvals when new commits are pushed and/or Require approval of the most recent reviewable push
It sounds like you might have worked with some repositories that were inconsistently configured.
- addeddiscussFeature changes that require discussion primarily among the GitHub CLI teamFeature changes that require discussion primarily among the GitHub CLI teamand removeddiscussFeature changes that require discussion primarily among the GitHub CLI teamFeature changes that require discussion primarily among the GitHub CLI team
on Jan 22, 2024 We discussed this and think it would be a good command to have. To me, it feels self contained and low risk. I'd be interested in opening this up to the community to implement. WDYT @andyfeller ?
Reacted by Andy Feller and Melissa XieWe discussed this and think it would be a good command to have. To me, it feels self contained and low risk. I'd be interested in opening this up to the community to implement. WDYT @andyfeller ?
Confirmed with Andy that we're good to let folks pick this up if they're interested!
- addedhelp wantedContributions welcomeContributions welcomeand removedneeds-triageneeds to be reviewedneeds to be revieweddiscussFeature changes that require discussion primarily among the GitHub CLI teamFeature changes that require discussion primarily among the GitHub CLI team
on Jan 31, 2024 @williammartin @andyfeller @mxie I just pushed a PR to add the
pr updatecommand.I so need this!
Good to know. It's on our backlog to give another review to. I would hope it'll be in the next release 2 weeks from now. 🤞
Reacted by Jean-Sebastien CarleAcceptance Criteria
Merge Commit
Given I have a PR that is one or more commits behind the base branch
And mycwdis in the repository containing that PR
When I rungh pr update [<number> | <url> | <branch>]
Then the remote PR branch is updated with a merge commit containing the commits in the base branch
And I see a message that the PR branch has been updated onstdoutRebase
Given I have a PR that is one or more commits behind the base branch
And mycwdis in the repository containing that PR
When I rungh pr update [<number> | <url> | <branch>] --rebase
Then the remote PR branch is updated with the commits being rebased on those from the base branch
And I see a message that the PR branch has been updated onstdoutPR Branch is in fork
Given I have a PR from a fork that is one or more commits behind the base branch
And mycwdis in the repository containing that PR
When I rungh pr update [<number> | <url> | <branch>]
Then the remote PR branch is updated with a merge commit containing the commits in the base branch
And I see a message that the PR branch has been updated onstdoutDefaults to current branch
Given I have a PR from a fork that is one or more commits behind the base branch
And mycwdis in the repository containing that PR
And the PR branch is currently checked out
When I rungh pr update
Then the remote PR branch is updated with a merge commit containing the commits in the base branch
And I see a message that the PR branch has been updated onstdoutAlready Up To Date
Given I have a PR that already contains all commits from the base branch
And mycwdis in the repository containing that PR
When I rungh pr update [<number> | <url> | <branch>]
Then I see a message onstdoutthat the PR branch is already up-to-dateConflicts
Given there are conflicts between the base branch and the PR branch
And mycwdis in the repository containing that PR
When I rungh pr update [<number> | <url> | <branch>]
Then I see a helpful message that conflicts must be resolved firstPR Not Found
Given my
cwdis in a repository that doesn't contain the PR I want to target
When I rungh pr update [<number> | <url> | <branch>]
Then I see a message that the PR could not be foundNot in Repo
Given my
cwdis not in a git repository
When I rungh pr update [<number> | <url> | <branch>]
Then I see a message that the current dir couldn't be resolved to a repositoryNote, the currently implemented message here isn't very good but let's stick with it for consistency.
Target different repo
Given I have a PR that is one or more commits behind the base branch
And mycwdis in a repository that doesn't contain the PR I want to target
When I rungh pr update [<number> | <url> | <branch>] --repo <repo containing PR>
Then the remote PR branch is updated with a merge commit containing the commits in the base branch
And I see a message that the PR branch has been updated onstdoutTarget different repo, no arg
When I run
gh pr update --repo <any repo>
Then I see a message that an argument must be provided when the--repoflag is used.Acceptance Criteria
1. Merge Commit
Given I have a PR that is one or more commits behind the base branch
And mycwdis in the repository containing that PR
When I rungh pr update [<number> | <url> | <branch>]
Then the remote PR branch is updated with a merge commit containing the commits in the base branch
And I see a message that the PR branch has been updated onstdout✓ Created repository williammartin/gh-8953-acceptance-1.sh on GitHub https://github.com/williammartin/gh-8953-acceptance-1.sh Cloning into 'gh-8953-acceptance-1.sh'... remote: Enumerating objects: 3, done. remote: Counting objects: 100% (3/3), done. remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 Receiving objects: 100% (3/3), done. Switched to a new branch 'pr-branch' [pr-branch 662d69d] change in pr 1 file changed, 1 insertion(+), 1 deletion(-) Enumerating objects: 5, done. Counting objects: 100% (5/5), done. Writing objects: 100% (3/3), 270 bytes | 270.00 KiB/s, done. Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 remote: remote: Create a pull request for 'pr-branch' on GitHub by visiting: remote: https://github.com/williammartin/gh-8953-acceptance-1.sh/pull/new/pr-branch remote: To https://github.com/williammartin/gh-8953-acceptance-1.sh.git * [new branch] pr-branch -> pr-branch branch 'pr-branch' set up to track 'origin/pr-branch'. Creating pull request for pr-branch into main in williammartin/gh-8953-acceptance-1.sh https://github.com/williammartin/gh-8953-acceptance-1.sh/pull/1 Switched to branch 'main' Your branch is up to date with 'origin/main'. [main c2e8901] change on main 1 file changed, 1 insertion(+) create mode 100644 NEW.md Enumerating objects: 4, done. Counting objects: 100% (4/4), done. Delta compression using up to 10 threads Compressing objects: 100% (2/2), done. Writing objects: 100% (3/3), 295 bytes | 295.00 KiB/s, done. Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 To https://github.com/williammartin/gh-8953-acceptance-1.sh.git 999cf6e..c2e8901 main -> main branch 'main' set up to track 'origin/main'. Switched to branch 'pr-branch' Your branch is up to date with 'origin/pr-branch'. ✓ PR branch updatedDetails
#!/usr/bin/env sh cli=/Users/williammartin/workspace/cli _tmp=/tmp _repo=gh-8953-acceptance-$(basename $0) _gh=$cli/bin/gh _pwd=$(pwd) cleanup () { cd $_pwd ARG=$? rm -rf "$_tmp/$_repo" gh repo delete --yes $_repo exit $ARG } trap cleanup EXIT cd $_tmp $_gh repo create --clone --private --add-readme $_repo $_gh repo clone $_repo cd $_repo git checkout -b pr-branch echo "updated in pr branch" > README.md git commit -am 'change in pr' git push -u origin pr-branch $_gh pr create --fill --title "test" --body '' git checkout main touch NEW.md echo "new file on main" > NEW.md git add NEW.md git commit -am 'change on main' git push -u origin main git checkout pr-branch $_gh pr update
2. Rebase
Given I have a PR that is one or more commits behind the base branch
And mycwdis in the repository containing that PR
When I rungh pr update [<number> | <url> | <branch>] --rebase
Then the remote PR branch is updated with the commits being rebased on those from the base branch
And I see a message that the PR branch has been updated onstdoutDetails
#!/usr/bin/env sh cli=/Users/williammartin/workspace/cli _tmp=/tmp _repo=gh-8953-acceptance-$(basename $0) _gh=$cli/bin/gh _pwd=$(pwd) cleanup () { cd $_pwd ARG=$? rm -rf "$_tmp/$_repo" gh repo delete $_repo exit $ARG } trap cleanup EXIT cd $_tmp $_gh repo create --private --add-readme $_repo $_gh repo clone $_repo cd $_repo git checkout -b pr-branch echo "updated in pr branch" > README.md git commit -am 'change in pr' git push -u origin pr-branch $_gh pr create --fill --title "test" --body '' git checkout main touch NEW.md echo "new file on main" > NEW.md git add NEW.md git commit -am 'change on main' git push -u origin main git checkout pr-branch $_gh pr update --rebase3. PR Branch is in fork
Given I have a PR from a fork that is one or more commits behind the base branch
And mycwdis in the repository containing that PR
When I rungh pr update [<number> | <url> | <branch>]
Then the remote PR branch is updated with a merge commit containing the commits in the base branch
And I see a message that the PR branch has been updated onstdout➜ 8963-acceptance ./3.sh ✓ Created repository williammartin/gh-8953-acceptance-3.sh on GitHub https://github.com/williammartin/gh-8953-acceptance-3.sh Cloning into 'gh-8953-acceptance-3.sh'... ✓ Created fork williammartin-test-org/gh-8953-acceptance-3.sh ? Would you like to add a remote for the fork? No Cloning into 'gh-8953-acceptance-3.sh-fork'... remote: Enumerating objects: 3, done. remote: Counting objects: 100% (3/3), done. remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 Receiving objects: 100% (3/3), done. From https://github.com/williammartin/gh-8953-acceptance-3.sh * [new branch] main -> upstream/main ! Repository williammartin/gh-8953-acceptance-3.sh set as the default repository. To learn more about the default repository, run: gh repo set-default --help Switched to a new branch 'pr-branch' [pr-branch 3f56d9d] change in pr 1 file changed, 1 insertion(+), 1 deletion(-) Enumerating objects: 5, done. Counting objects: 100% (5/5), done. Writing objects: 100% (3/3), 269 bytes | 269.00 KiB/s, done. Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 remote: remote: Create a pull request for 'pr-branch' on GitHub by visiting: remote: https://github.com/williammartin-test-org/gh-8953-acceptance-3.sh/pull/new/pr-branch remote: To https://github.com/williammartin-test-org/gh-8953-acceptance-3.sh.git * [new branch] pr-branch -> pr-branch branch 'pr-branch' set up to track 'origin/pr-branch'. Creating pull request for williammartin-test-org:pr-branch into main in williammartin/gh-8953-acceptance-3.sh https://github.com/williammartin/gh-8953-acceptance-3.sh/pull/1 /tmp/gh-8953-acceptance-3.sh [main 62e17c3] change on main 1 file changed, 1 insertion(+) create mode 100644 NEW.md Enumerating objects: 4, done. Counting objects: 100% (4/4), done. Delta compression using up to 10 threads Compressing objects: 100% (2/2), done. Writing objects: 100% (3/3), 295 bytes | 295.00 KiB/s, done. Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 To https://github.com/williammartin/gh-8953-acceptance-3.sh.git 094d19e..62e17c3 main -> main branch 'main' set up to track 'origin/main'. Already on 'pr-branch' Your branch is up to date with 'origin/pr-branch'. ✓ PR branch updatedDetails
#!/usr/bin/env sh cli=/Users/williammartin/workspace/cli _tmp=/tmp _repo=gh-8953-acceptance-$(basename $0) _gh=$cli/bin/gh _pwd=$(pwd) cleanup () { cd $_pwd ARG=$? rm -rf "$_tmp/$_repo" rm -rf "$_tmp/$_repo-fork" gh repo delete $_repo gh repo delete williammartin-test-org/$_repo exit $ARG } trap cleanup EXIT cd $_tmp $_gh repo create --clone --private --add-readme $_repo cd $_repo $_gh repo fork --org williammartin-test-org cd $_tmp $_gh repo clone williammartin-test-org/$_repo "$_repo"-fork cd "$_repo-fork" git checkout -b pr-branch echo "updated in pr branch" > README.md git commit -am 'change in pr' git push -u origin pr-branch $_gh pr create --fill --title "test" --body '' echo $_tmp/$_repo cd "$_tmp/$_repo" touch NEW.md echo "new file on main" > NEW.md git add NEW.md git commit -am 'change on main' git push -u origin main cd "$_tmp/$_repo-fork" git checkout pr-branch $_gh pr update
4. Defaults to current branch
Given I have a PR from a fork that is one or more commits behind the base branch
And mycwdis in the repository containing that PR
And the PR branch is currently checked out
When I rungh pr update
Then the remote PR branch is updated with a merge commit containing the commits in the base branch
And I see a message that the PR branch has been updated onstdoutThis is demonstrated by the previous examples by accident.
5. Already Up To Date
Given I have a PR that already contains all commits from the base branch
And mycwdis in the repository containing that PR
When I rungh pr update [<number> | <url> | <branch>]
Then I see a message onstdoutthat the PR branch is already up-to-date➜ 8963-acceptance ./5.sh ✓ Created repository williammartin/gh-8953-acceptance-5.sh on GitHub https://github.com/williammartin/gh-8953-acceptance-5.sh Cloning into 'gh-8953-acceptance-5.sh'... remote: Enumerating objects: 3, done. remote: Counting objects: 100% (3/3), done. remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 Receiving objects: 100% (3/3), done. Switched to a new branch 'pr-branch' [pr-branch 107cc09] change in pr 1 file changed, 1 insertion(+), 1 deletion(-) Enumerating objects: 5, done. Counting objects: 100% (5/5), done. Writing objects: 100% (3/3), 269 bytes | 269.00 KiB/s, done. Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 remote: remote: Create a pull request for 'pr-branch' on GitHub by visiting: remote: https://github.com/williammartin/gh-8953-acceptance-5.sh/pull/new/pr-branch remote: To https://github.com/williammartin/gh-8953-acceptance-5.sh.git * [new branch] pr-branch -> pr-branch branch 'pr-branch' set up to track 'origin/pr-branch'. Creating pull request for pr-branch into main in williammartin/gh-8953-acceptance-5.sh https://github.com/williammartin/gh-8953-acceptance-5.sh/pull/1 ✓ PR branch already up-to-dateDetails
#!/usr/bin/env sh cli=/Users/williammartin/workspace/cli _tmp=/tmp _repo=gh-8953-acceptance-$(basename $0) _gh=$cli/bin/gh _pwd=$(pwd) cleanup () { cd $_pwd ARG=$? rm -rf "$_tmp/$_repo" gh repo delete $_repo exit $ARG } trap cleanup EXIT cd $_tmp $_gh repo create --private --add-readme $_repo $_gh repo clone $_repo cd $_repo git checkout -b pr-branch echo "updated in pr branch" > README.md git commit -am 'change in pr' git push -u origin pr-branch $_gh pr create --fill --title "test" --body '' $_gh pr update
6. Conflicts
Given there are conflicts between the base branch and the PR branch
And mycwdis in the repository containing that PR
When I rungh pr update [<number> | <url> | <branch>]
Then I see a helpful message that conflicts must be resolved first➜ 8963-acceptance ./6.sh ✓ Created repository williammartin/gh-8953-acceptance-6.sh on GitHub https://github.com/williammartin/gh-8953-acceptance-6.sh Cloning into 'gh-8953-acceptance-6.sh'... remote: Enumerating objects: 3, done. remote: Counting objects: 100% (3/3), done. remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 Receiving objects: 100% (3/3), done. Switched to a new branch 'pr-branch' [pr-branch 74b7e5c] change in pr 1 file changed, 1 insertion(+), 1 deletion(-) Enumerating objects: 5, done. Counting objects: 100% (5/5), done. Writing objects: 100% (3/3), 270 bytes | 270.00 KiB/s, done. Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 remote: remote: Create a pull request for 'pr-branch' on GitHub by visiting: remote: https://github.com/williammartin/gh-8953-acceptance-6.sh/pull/new/pr-branch remote: To https://github.com/williammartin/gh-8953-acceptance-6.sh.git * [new branch] pr-branch -> pr-branch branch 'pr-branch' set up to track 'origin/pr-branch'. Creating pull request for pr-branch into main in williammartin/gh-8953-acceptance-6.sh https://github.com/williammartin/gh-8953-acceptance-6.sh/pull/1 Switched to branch 'main' Your branch is up to date with 'origin/main'. [main fe9f6ab] change on main (conflicting) 1 file changed, 1 insertion(+), 1 deletion(-) Enumerating objects: 5, done. Counting objects: 100% (5/5), done. Delta compression using up to 10 threads Compressing objects: 100% (2/2), done. Writing objects: 100% (3/3), 314 bytes | 314.00 KiB/s, done. Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 To https://github.com/williammartin/gh-8953-acceptance-6.sh.git 23aa2d1..fe9f6ab main -> main branch 'main' set up to track 'origin/main'. Switched to branch 'pr-branch' Your branch is up to date with 'origin/pr-branch'. X Cannot update PR branch due to conflictsDetails
#!/usr/bin/env sh cli=/Users/williammartin/workspace/cli _tmp=/tmp _repo=gh-8953-acceptance-$(basename $0) _gh=$cli/bin/gh _pwd=$(pwd) cleanup () { cd $_pwd ARG=$? rm -rf "$_tmp/$_repo" gh repo delete $_repo exit $ARG } trap cleanup EXIT cd $_tmp $_gh repo create --private --add-readme $_repo $_gh repo clone $_repo cd $_repo git checkout -b pr-branch echo "updated in pr branch" > README.md git commit -am 'change in pr' git push -u origin pr-branch $_gh pr create --fill --title "test" --body '' git checkout main echo "modified in base branch to make it conflicting with the pr" > README.md git add README.md git commit -am 'change on main (conflicting)' git push -u origin main git checkout pr-branch $_gh pr update
7. PR Not Found
Given my
cwdis in a repository that doesn't contain the PR I want to target
When I rungh pr update [<number> | <url> | <branch>]
Then I see a message that the PR could not be found➜ 8963-acceptance ./7.sh ✓ Created repository williammartin/gh-8953-acceptance-7.sh on GitHub https://github.com/williammartin/gh-8953-acceptance-7.sh Cloning into 'gh-8953-acceptance-7.sh'... remote: Enumerating objects: 3, done. remote: Counting objects: 100% (3/3), done. remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 Receiving objects: 100% (3/3), done. no pull requests found for branch "main"Details
#!/usr/bin/env sh cli=/Users/williammartin/workspace/cli _tmp=/tmp _repo=gh-8953-acceptance-$(basename $0) _gh=$cli/bin/gh _pwd=$(pwd) cleanup () { cd $_pwd ARG=$? rm -rf "$_tmp/$_repo" gh repo delete $_repo exit $ARG } trap cleanup EXIT cd $_tmp $_gh repo create --private --add-readme $_repo $_gh repo clone $_repo cd $_repo $_gh pr update
8. Not in Repo
Given my
cwdis not in a git repository
When I rungh pr update [<number> | <url> | <branch>]
Then I see a message that the current dir couldn't be resolved to a repository➜ 8963-acceptance ./8.sh failed to run git: fatal: not a git repository (or any of the parent directories): .gitDetails
#!/usr/bin/env sh cli=/Users/williammartin/workspace/cli _tmp=/tmp _repo=gh-8953-acceptance-$(basename $0) _gh=$cli/bin/gh _pwd=$(pwd) cleanup () { cd $_pwd rm -rf "$_tmp/$_repo" exit $ARG } trap cleanup EXIT mkdir "$_tmp/$_repo" cd "$_tmp/$_repo" $_gh pr update
9. Target different repo
Given I have a PR that is one or more commits behind the base branch
And mycwdis in a repository that doesn't contain the PR I want to target
When I rungh pr update [<number> | <url> | <branch>] --repo <repo containing PR>
Then the remote PR branch is updated with a merge commit containing the commits in the base branch
And I see a message that the PR branch has been updated onstdout➜ 8963-acceptance ./9.sh Cloning into 'gh-8953-acceptance-9.sh'... remote: Enumerating objects: 3, done. remote: Counting objects: 100% (3/3), done. remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 Receiving objects: 100% (3/3), done. Switched to a new branch 'pr-branch' [pr-branch c95635b] change in pr 1 file changed, 1 insertion(+), 1 deletion(-) Enumerating objects: 5, done. Counting objects: 100% (5/5), done. Writing objects: 100% (3/3), 270 bytes | 270.00 KiB/s, done. Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 remote: remote: Create a pull request for 'pr-branch' on GitHub by visiting: remote: https://github.com/williammartin/gh-8953-acceptance-9.sh/pull/new/pr-branch remote: To https://github.com/williammartin/gh-8953-acceptance-9.sh.git * [new branch] pr-branch -> pr-branch branch 'pr-branch' set up to track 'origin/pr-branch'. Switched to branch 'main' Your branch is up to date with 'origin/main'. [main eba6d75] change on main 1 file changed, 1 insertion(+) create mode 100644 NEW.md Enumerating objects: 4, done. Counting objects: 100% (4/4), done. Delta compression using up to 10 threads Compressing objects: 100% (2/2), done. Writing objects: 100% (3/3), 295 bytes | 295.00 KiB/s, done. Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 To https://github.com/williammartin/gh-8953-acceptance-9.sh.git bafc685..eba6d75 main -> main branch 'main' set up to track 'origin/main'. Switched to branch 'pr-branch' Your branch is up to date with 'origin/pr-branch'. /Users/williammartin/workspace/cli/bin/gh pr update https://github.com/williammartin/gh-8953-acceptance-9.sh/pull/1 --repo https://github.com/williammartin/gh-8953-acceptance-9.sh ✓ PR branch updatedDetails
#!/usr/bin/env sh cli=/Users/williammartin/workspace/cli _tmp=/tmp _repo=gh-8953-acceptance-$(basename $0) _gh=$cli/bin/gh _pwd=$(pwd) cleanup () { cd $_pwd ARG=$? rm -rf "$_tmp/$_repo" gh repo delete $_repo exit $ARG } trap cleanup EXIT cd $_tmp repo=$($_gh repo create --private --add-readme $_repo) $_gh repo clone $_repo cd $_repo git checkout -b pr-branch echo "updated in pr branch" > README.md git commit -am 'change in pr' git push -u origin pr-branch pr=$($_gh pr create --fill --title "test" --body '') git checkout main touch NEW.md echo "new file on main" > NEW.md git add NEW.md git commit -am 'change on main' git push -u origin main git checkout pr-branch cd $_tmp echo "$_gh pr update $pr --repo $repo" $_gh pr update $pr --repo $repo
10. Target different repo, no arg
When I run
gh pr update --repo <any repo>
Then I see a message that an argument must be provided when the--repoflag is used.➜ 8963-acceptance ./10.sh flag needs an argument: --repo Usage: gh pr update [<number> | <url> | <branch>] [flags] Flags: --rebase Update PR branch by rebasing oDetails
#!/usr/bin/env sh cli=/Users/williammartin/workspace/cli _gh=$cli/bin/gh $_gh pr update --repo $repoJust as a note, we agreed in #8953 that this would be
pr update-branchto avoid some ambiguity withpr edit. Hope it solves your problems!



Describe the feature or problem you’d like to solve
The GH web interface and REST API support a PR "update" function, which does a merge or a rebase, with the rest API only supporting the merge commit option.
See: Keeping You Pull Request In Sync
It would be nice to have this function available in the CLI toolkit, meaning the direct GH API version of this, not a pseudo-update via doing the various git syncing and updating locally.
Proposed solution
Introduce a
gh pr updatecommand which:Additional context
As mentioned above, my personal preference is the update itself occurs using the API object, instead of doing the local only version of a merge/rebase on the base branch. Since I'm trying to mimic the Web UI button, the reasons that exists versus Github telling us to "get good" at doing branch updates I would apply to this command as well.