You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Is there a way to pass --no-verify when creating a PR? #684
Sometimes I would like to be able to create a PR without running the pre-commitandcommit-msg pre-push hooks when pushing the changes. Is that possible?
Edit: Replaced pre-commit and commit-msg with pre-push.
During pr create, the only git command that we shell out to is git push. Therefore the only git hook that I can imagine running is the pre-push hook. We don't create commits, so I'm confused as to how pre-commit and commit-msg are running for you. Could you check whether some of your git hooks invoke other hooks?
We did not have a plan to support --no-verify, but we do have a plan to respect an already-pushed branch. That way, if you do something like this, gh wouldn't shell out to git at all:
I was just hoping I can do it all through gh instead of having to push the branch via git with the --no-verify flag and then creating the PR through gh as you suggested.
I was just hoping I can do it all through gh instead of having to push the branch via git with the --no-verify flag
That makes sense. We will consider supporting a flag such as --no-verify. But it's likelier that before that we already ship a fix that respects if a branch has been manually push, which at least gives you a temporary workaround.
We did not have a plan to support --no-verify, but we do have a plan to respect an already-pushed branch. That way, if you do something like this, gh wouldn't shell out to git at all:
git push --no-verify <remote> HEAD
gh pr create
Just a note that the feature described here just landed in master and is slated for release this week. No plan yet for adding --no-verify to gh pr create yet, but we will keep this and related requests in mind!
But in the output, I can still see the pre-push hooks running for gh pr create
...
Creating pull request for $BRANCH_NAME into master in $REPO_NAME
husky > pre-push (node v12.16.2)
...
The branch is successfully created on Github, since I am passing --no-verify flag with git push. However, creating a PR is failing because I cannot pass the --no-verify flag with gh pr create
I am using the latest version of gh cli
$ gh --version
gh version 0.11.1 (2020-07-28)
https://github.com/cli/cli/releases/tag/v0.11.1
I just tried to reproduce this using the commands you provided, and I couldn't, but it's still possible that there is a bug here. If you use the DEBUG=1 environment variable when running gh, you will get verbose output that should include all underlying invocations of git. Can you share with us the output? (You may anonymize branch names.)
Nothing stands out to me as potentially wrong in the log. 😕 Could you check the output of git show-ref --verify -- HEAD refs/remotes/origin/$BRANCH_NAME refs/remotes/origin/$BRANCH_NAME after you put in your actual branch name? It should be something like this, where you can see that the commit SHAs are identical:
$ git show-ref --verify -- HEAD refs/remotes/origin/"$(git branch --show-current)"
27b0c83f1c1f2d6e705426cf1d3926f0c5b1fa47 HEAD
27b0c83f1c1f2d6e705426cf1d3926f0c5b1fa47 refs/remotes/origin/gh-pre-push-test
oh, interesting, not sure why, but getting an error when trying to get the output of the above command
$ git show-ref --verify -- HEAD refs/remotes/origin/$BRANCH_NAME refs/remotes/origin/$BRANCH_NAME
Output
e66d5583a31bc87298d4b8a62daa9922531226fa HEAD
fatal: 'refs/remotes/origin/$BRANCH_NAME' - not a valid ref
Could you explain what this command means? I can see the same commit SHA on Github on $BRANCH_NAME, so not quite sure why its erring on my local machine.
@nl-ria What usually happens when you do something like git push origin mybranch is that git performs the push, but also creates what it calls a "remote-tracking branch". In this case, the remote-tracking branch is called origin/mybranch for short, but the fully qualified ref name for it would be refs/remotes/origin/mybranch.
Your git push obviously succeeded, but the remote-tracking branch was not created and thus gh could not detect that the branch was already pushed. I'm not sure why is that, but it could be due to unconventional git config --get-all remote.origin.fetch configuration, or some other factors.
In any case, it's clear to me from your and other people's reported cases that we need an explicit option to disallow the auto-fork/auto-push behavior so that we don't rely on brittle detection mechanisms. Thank you for your input! Unfortunately, I do not have a suitable workaround to suggest right now.
Activity
mislav commentedon Mar 20, 2020
Hi, thanks for the suggestion!
During
pr create, the only git command that we shell out to isgit push. Therefore the only git hook that I can imagine running is thepre-pushhook. We don't create commits, so I'm confused as to howpre-commitandcommit-msgare running for you. Could you check whether some of your git hooks invoke other hooks?We did not have a plan to support
--no-verify, but we do have a plan to respect an already-pushed branch. That way, if you do something like this, gh wouldn't shell out to git at all:Would this be sufficient?
CExWHamdan commentedon Mar 20, 2020
Sorry, I meant pre-push hooks.
I was just hoping I can do it all through
ghinstead of having to push the branch viagitwith the--no-verifyflag and then creating the PR throughghas you suggested.Hope you consider that in the future. Thank you!
mislav commentedon Mar 26, 2020
That makes sense. We will consider supporting a flag such as
--no-verify. But it's likelier that before that we already ship a fix that respects if a branch has been manually push, which at least gives you a temporary workaround.mislav commentedon Mar 30, 2020
Just a note that the feature described here just landed in master and is slated for release this week. No plan yet for adding
--no-verifytogh pr createyet, but we will keep this and related requests in mind!nl-ria commentedon Aug 17, 2020
Hi ! Unfortunately, the fix #704 doesnt seem to be working as expected.
I am doing the following to create a PR using
ghand making my commits and push usinggit, since there is no way to pass--no-verifyingh pr create.$ git push --no-verify -u origin $BRANCH_NAME $ gh pr createBut in the output, I can still see the pre-push hooks running for
gh pr createThe branch is successfully created on Github, since I am passing
--no-verifyflag withgit push. However, creating a PR is failing because I cannot pass the--no-verifyflag withgh pr createI am using the latest version of
gh climislav commentedon Aug 17, 2020
@nl-ria Thank you for reporting!
I just tried to reproduce this using the commands you provided, and I couldn't, but it's still possible that there is a bug here. If you use the
DEBUG=1environment variable when runninggh, you will get verbose output that should include all underlying invocations ofgit. Can you share with us the output? (You may anonymize branch names.)nl-ria commentedon Aug 17, 2020
@mislav - thanks for getting back so quickly, here is output in debug mode
Running command
$ gh pr create --title "$title" --body "$body"Output
mislav commentedon Aug 17, 2020
@nl-ria Thank you for the debug output!
Nothing stands out to me as potentially wrong in the log. 😕 Could you check the output of
git show-ref --verify -- HEAD refs/remotes/origin/$BRANCH_NAME refs/remotes/origin/$BRANCH_NAMEafter you put in your actual branch name? It should be something like this, where you can see that the commit SHAs are identical:And also please your
git version🙇nl-ria commentedon Aug 17, 2020
oh, interesting, not sure why, but getting an error when trying to get the output of the above command
Output
Could you explain what this command means? I can see the same commit SHA on Github on $BRANCH_NAME, so not quite sure why its erring on my local machine.
My Git version :
mislav commentedon Aug 17, 2020
@nl-ria What usually happens when you do something like
git push origin mybranchis that git performs the push, but also creates what it calls a "remote-tracking branch". In this case, the remote-tracking branch is calledorigin/mybranchfor short, but the fully qualified ref name for it would berefs/remotes/origin/mybranch.Your git push obviously succeeded, but the remote-tracking branch was not created and thus gh could not detect that the branch was already pushed. I'm not sure why is that, but it could be due to unconventional
git config --get-all remote.origin.fetchconfiguration, or some other factors.In any case, it's clear to me from your and other people's reported cases that we need an explicit option to disallow the auto-fork/auto-push behavior so that we don't rely on brittle detection mechanisms. Thank you for your input! Unfortunately, I do not have a suitable workaround to suggest right now.