Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ghstack land merges PR to base branch not upstream main #243

Closed
Xia-Weiwen opened this issue Apr 1, 2024 · 2 comments
Closed

ghstack land merges PR to base branch not upstream main #243

Xia-Weiwen opened this issue Apr 1, 2024 · 2 comments

Comments

@Xia-Weiwen
Copy link

Xia-Weiwen commented Apr 1, 2024

Hi. I have 4 stacked PRs for PyTorch. When I tried to land the first PR of the stack by ghstack land $PR_URL, I got the following error, and the PR was merged to the ghstack base branch instead of the PyTorch main. How can I land it to the main branch? Or can I reopen the PR? The other stacked PRs are intact. Thanks.

# Command I ran
$ ghstack land https://github.com/pytorch/pytorch/pull/122288

# Output
$ git fetch --prune upstream
...
$ git merge-base upstream/main upstream/gh/Xia-Weiwen/18/orig
$ git rev-list --reverse --header '^56451cd49d9cf94b49197e09dec13426bb1a5370' upstream/gh/Xia-Weiwen/18/orig
$ git symbolic-ref --short HEAD
$ git checkout upstream/main
Note: switching to 'upstream/main'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at 6b1f13ea2f3 Add skip models by device in Dynamo Test (#122591)
$ git cherry-pick upstream/gh/Xia-Weiwen/18/orig
$ git push upstream upstream/gh/Xia-Weiwen/18/head:gh/Xia-Weiwen/18/base
remote:
remote: GitHub found 4 vulnerabilities on pytorch/pytorch's default branch (4 moderate). To find out more, visit:
remote:      https://github.com/pytorch/pytorch/security/dependabot
remote:
To https://github.com/pytorch/pytorch.git
   a3aab49f3e1..31a6dc33209  upstream/gh/Xia-Weiwen/18/head -> gh/Xia-Weiwen/18/base
$ git push upstream HEAD:refs/heads/main
remote: error: GH006: Protected branch update failed for refs/heads/main.
remote: error: You're not authorized to push to this branch. Visit https://docs.github.com/articles/about-protected-branches/ for more information.
To https://github.com/pytorch/pytorch.git
 ! [remote rejected]         HEAD -> main (protected branch hook declined)
error: failed to push some refs to 'https://github.com/pytorch/pytorch.git'
$ git checkout inductor_qlinear_binary
Warning: you are leaving 1 commit behind, not connected to
any of your branches:

  b9bff14519e [Quant][Inductor] Add qlinear_pointwise.binary op for X86Inductor backend

If you want to keep it by creating a new branch, this may be a good time
to do so with:

 git branch <new-branch-name> b9bff14519e

Switched to branch 'inductor_qlinear_binary'
ERROR: Fatal exception
Traceback (most recent call last):
  File "/home/weiwen/.conda/envs/int8-dev/lib/python3.9/site-packages/ghstack/logs.py", line 105, in manager
    yield
  File "/home/weiwen/.conda/envs/int8-dev/lib/python3.9/site-packages/ghstack/cli.py", line 46, in cli_context
    yield shell, config, github
  File "/home/weiwen/.conda/envs/int8-dev/lib/python3.9/site-packages/ghstack/cli.py", line 135, in land
    ghstack.land.main(
  File "/home/weiwen/.conda/envs/int8-dev/lib/python3.9/site-packages/ghstack/land.py", line 176, in main
    sh.git(
  File "/home/weiwen/.conda/envs/int8-dev/lib/python3.9/site-packages/ghstack/shell.py", line 288, in git
    return self._maybe_rstrip(self.sh(*(("git",) + args), **kwargs))
  File "/home/weiwen/.conda/envs/int8-dev/lib/python3.9/site-packages/ghstack/shell.py", line 220, in sh
    raise RuntimeError(
RuntimeError: git push upstream HEAD:refs/heads/main failed with exit code 1
@ezyang
Copy link
Owner

ezyang commented Apr 8, 2024

This is the protected branch merge problem. Need a land bot with permissions to merge to protected branch. See #50 for a community contributed bot

@Xia-Weiwen
Copy link
Author

Got it. Thanks. I reopened the PR by removing ghstack-related info from the commit message and rerunning ghstack.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants