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
careful: force-push check fires on a plain git push when a later command in the same line has a +token or -f (e.g. date +%F) #4601
The destructive-command check asks for confirmation ("Destructive: git force-push rewrites remote history") on an ordinary push when the same Bash command contains a + token or -f somewhere else. This command triggered it:
The first finds git push, and the second finds +%F from date. The second grep isn't limited to the push's own arguments, so any later +token or -f anywhere in the line counts. That includes date +%F, chmod +x, rm -f, tail -f, and sort -f. Since the check is a PreToolUse hook, it prompts even in bypass-permissions mode.
Expected
Match force flags only among the arguments of the git push itself, stopping at the first ;, &&, ||, |, newline, or redirect. A rough version:
A second case from the same check: it also fires on text inside a quoted argument, with no push being run at all. Filing this issue tripped it:
gh issue create -R garrytan/gstack --title "careful: force-push check fires on a plain git push when a later command in the same line has a +token or -f (e.g. date +%F)" --body-file report.md
The only git push, +token, and -f here are words in the quoted --title. The commit-message masking (mask-commit-message.awk) only applies to git commit, so quoted arguments to any other command, such as gh issue create --title, gh pr create --body, or echo "...", are matched as if they were commands. Masking every quoted string before the force-push match, or matching only an unquoted git push command word, would cover both cases.
The first case is fixed: since #4513 (55aaa6c, released in v1.102.0.0) the check reads force flags from the push's own arguments only. On main (bd77c8c) your exact command, and git push -q origin feat && chmod +x foo && rm -f bar, pass with no prompt, while git push -f, git push --force and git push origin +feat still ask. You're on 1.101.0.0, so upgrading clears it.
The second case still reproduces on main: a gh issue create whose quoted title mentions git push and a +token gets the force-push prompt. I'm leaving this open as a low-severity bug for that part. Changes to this check have to keep everything it currently catches, so it won't be a quick one-line change.
Picking up the second case, the quoted text that mentions git push and a +token. Your first case was fixed in v1.102.0.0. A maintainer agent working on the destructive-command check (our tracking thread GSTA-685) will first reproduce it on current main. Changes to this check only ever allow a command when it's a different spelling of one the check already allows, so a fix has to fit that rule. If it reproduces and fits, we'll close this with a link to the change. If it no longer reproduces, we'll close it and say what changed.
Thanks for the second case. Fixed in #4604 (9055979): the quoted --title/--body (-t/-b) of gh issue and gh pr create, comment and edit is now read as text, so your gh issue create --title "... git push ... +token ... -f" command no longer prompts. A command substitution inside double quotes, a later statement, a pipe, echo and bash -c are still checked. The first case was already fixed in v1.102.0.0 (#4513). It ships in the next release.
Activity
TayTaySwizzle commentedon Nov 21, 2026
A second case from the same check: it also fires on text inside a quoted argument, with no push being run at all. Filing this issue tripped it:
gh issue create -R garrytan/gstack --title "careful: force-push check fires on a plain git push when a later command in the same line has a +token or -f (e.g. date +%F)" --body-file report.mdThe only
git push,+token, and-fhere are words in the quoted--title. The commit-message masking (mask-commit-message.awk) only applies togit commit, so quoted arguments to any other command, such asgh issue create --title,gh pr create --body, orecho "...", are matched as if they were commands. Masking every quoted string before the force-push match, or matching only an unquotedgit pushcommand word, would cover both cases.capy-ai commentedon Nov 21, 2026
Thanks for the report and the second case.
The first case is fixed: since #4513 (55aaa6c, released in v1.102.0.0) the check reads force flags from the push's own arguments only. On main (bd77c8c) your exact command, and
git push -q origin feat && chmod +x foo && rm -f bar, pass with no prompt, whilegit push -f,git push --forceandgit push origin +featstill ask. You're on 1.101.0.0, so upgrading clears it.The second case still reproduces on main: a
gh issue createwhose quoted title mentionsgit pushand a+tokengets the force-push prompt. I'm leaving this open as a low-severity bug for that part. Changes to this check have to keep everything it currently catches, so it won't be a quick one-line change.capy-ai commentedon Nov 22, 2026
Picking up the second case, the quoted text that mentions
git pushand a+token. Your first case was fixed in v1.102.0.0. A maintainer agent working on the destructive-command check (our tracking thread GSTA-685) will first reproduce it on current main. Changes to this check only ever allow a command when it's a different spelling of one the check already allows, so a fix has to fit that rule. If it reproduces and fits, we'll close this with a link to the change. If it no longer reproduces, we'll close it and say what changed.Destructive-command check closes four review gaps and stops asking ab…
capy-ai commentedon Nov 22, 2026
Thanks for the second case. Fixed in #4604 (9055979): the quoted
--title/--body(-t/-b) ofgh issueandgh prcreate, comment and edit is now read as text, so yourgh issue create --title "... git push ... +token ... -f"command no longer prompts. A command substitution inside double quotes, a later statement, a pipe,echoandbash -care still checked. The first case was already fixed in v1.102.0.0 (#4513). It ships in the next release.Destructive-command check catches more force pushes and outside delet…