Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

`gh stack push` resolves an empty remote and silently pushes nothing when `branch.<name>.remote` is `.`

未关闭
#412 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
55/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
冷清
技术栈
git, github, go
领域
cli

调研方向

gh stack push 使用的远程自动检测和 push 路径入手,然后将它们对 branch.<name>.remote = . 的处理与单远程和 remote.pushDefault 的情况进行比较。使用上面描述的命令和仓库复现该问题,并验证未解析的远程会明确失败、实际的 ref 移动会被报告,以及在没有任何内容被 push 时退出状态为非零。

由索引模型根据 Issue 内容生成。

描述

bug topic: cli - push

Summary

When a stack branch's branch.<name>.remote is . (the local repository), gh stack push resolves the push remote to an empty string, pushes nothing, and reports success:

$ gh stack push
Pushing 2 branches to ....
✓ Pushed 2 branches
To create PRs for this stack, run `gh stack submit`

$ git ls-remote --heads origin | grep probe
                       # nothing — no ref was created

Note the blank remote name between "to" and the ellipsis. Exit status is 0.

gh stack submit then fails PR creation, but the error describes a state problem rather than the push failure that caused it, and the run still ends on a success line:

$ gh stack submit --auto
Checking stack state...
Pushing to ....
⚠ failed to create PR for probe-one: creating PR: GraphQL: Head sha can't be blank,
  Base sha can't be blank, No commits between main and probe-one,
  Head ref must be a branch (createPullRequest)
✓ Pushed and synced 2 branches

This is a single-remote repository. origin is the only remote, and it is correct.

Root cause

branch.<name>.remote = . is a normal git configuration meaning "the upstream is a local branch". Anyone with branch.autoSetupMerge = always in their git config gets it automatically on every git switch -c from a local branch — which is exactly how a stack is built, so every branch in the stack has it.

Remote auto-detection appears to read branch.<name>.remote, find ., and yield an empty remote name rather than falling back to the single remote / origin.

Isolated by toggling it:

branch.autoSetupMerge branch.<name>.remote gh stack push branches pushed
always . Pushing 2 branches to .... 0
unset unset Pushing 2 branches to origin... 2

Also fixed by setting remote.pushDefault = origin; unsetting it reproduces the failure again, deterministically.

Reproduction

git config --global branch.autoSetupMerge always   # or set it locally

git switch main
git switch -c probe-one && echo p1 > p1.txt && git add . && git commit -m "p1"
git switch -c probe-two && echo p2 > p2.txt && git add . && git commit -m "p2"
git switch probe-one

git config --get branch.probe-one.remote           # -> .
gh stack init probe-one probe-two
gh stack push                                      # "Pushing 2 branches to ...." / "✓ Pushed 2 branches"
git ls-remote --heads origin | grep probe          # -> nothing

Public repo with two stacks set up for this: https://github.com/xn/gh-stack-repro

Expected

  • Fail loudly when the push remote cannot be resolved, rather than pushing to an empty remote name.
  • Never print ✓ Pushed N branches unless refs actually moved — report per-branch results, and exit non-zero when nothing was pushed.
  • Treat branch.<name>.remote = . as "no usable remote for this branch" and fall back to the single remote / origin / remote.pushDefault.

Workaround

gh stack push --remote origin, or git config remote.pushDefault origin.

Environment

  • gh 2.97.0
  • gh-stack v0.1.0
  • git 2.50.1
  • macOS 26.4.1, darwin/arm64

Related

Same GraphQL error signature as #219 and #381, but a different root cause — those are about which repository the API calls target in multi-remote/fork clones. This one is a single-remote clone where the push target itself resolves to empty and no ref is ever created. #45 is a third variant (SSH host alias); ruled out here — the failure reproduces with a plain https:// remote and a pristine global config.

主要语言
Go
星标
1.5k
派生
73
平均合并
1 天 8 小时
30 天内合并 PR
7

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

github/gh-stack 的其他 Issue

查看 github/gh-stack 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。