Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

[Bug][Windows/macOS] 从 origin/main 新建功能分支后,推送可能直接更新远端 main

Open
#1,272 2 comments 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 1 day

@milestone-17 is already working on this.

Since Oct 17, 2026.

Assessment

This issue has not been assessed yet.

Description

bug claimed review: medium

问题

从 origin/main 新建并切换到异名功能分支(例如 feature/topic)后,Git 默认可能将其 upstream 自动配置为 origin/main。Lithe 推送时直接使用 upstream 分支名构造显式 refspec,导致功能分支提交可能直接更新远端 main。

影响 Windows 和 macOS:两平台相关创建分支及推送入口均调用同一 Rust Core 行为。Windows 有用户截图反馈;macOS 影响依据为源码调用链核对,尚未运行两平台完整 GUI 复现。隔离本地 Git 仓库已验证底层命令行为。用户使用的发行版本尚未确认。

复现

前提:远端允许更新 main,采用通常的 branch.autoSetupMerge=true,没有覆盖推送远端的特殊配置。

  1. Git 日志右键 origin/main,选择“从 origin/main 新建分支”。
  2. 输入 feature/topic 并切换到该分支。
  3. 新建提交后,在 Lithe 中推送或使用“提交并推送”。
  4. 检查远端目标及 upstream。

隔离仓库验证的命令链:

git switch -c feature/topic refs/remotes/origin/main
git branch -vv
# feature/topic tracks origin/main
git config --get branch.feature/topic.merge
# refs/heads/main

# Lithe 生成的等价命令:
git push --dry-run origin refs/heads/feature/topic:refs/heads/main
# feature/topic -> main

相同状态下,普通 git push 配合 push.default=simple 会因分支名不匹配拒绝执行;Lithe 使用显式 refspec 则可通过 dry-run。远端保护规则可能阻止真正更新,但不能依赖远端保护代替正确产品行为。

截图中 HEAD -> feature/topic, origin/main, origin/HEAD 仅说明引用指向同一提交,不能单独证明 upstream 配置。现场确认还需结合 git branch -vv、分支配置及实际推送命令。

原因与跨平台证据

核对版本:03c84e5dac088971654996c834c6746aa787707a。

建议设计

  1. 区分“从远端分支派生功能分支”和“检出远端分支进行跟踪”。从 origin/main 创建异名功能分支时,不隐式将源分支设为后续推送目标;首次默认发布到同名远端功能分支,成功后建立 upstream。
  2. 推送界面始终展示完整方向,如 feature/topic → origin/feature/topic,标明是否新建远端分支;成功结果也显示实际目标。
  3. 对已有异名 upstream,推送前要求明确选择“发布到同名远端分支(推荐)”或“继续推送到现有 upstream”。选择后者时按钮明确写出目标,如“推送到 main”。保留用户有意配置异名 upstream 的能力,不能静默改写。
  4. 普通同名分支推送不增加通用二次确认;异名目标通过明确选择解决,避免连续堆叠确认框。
  5. “提交并推送”走相同检查,尽量在提交前完成目标选择;实际推送保留预览后状态变化校验。
  6. 共享 Core 统一目标解析/校验语义,两平台一致消费,覆盖所有推送入口。

验收标准

  • Windows / macOS 从 origin/main 新建异名功能分支,首次默认发布到同名远端分支,不更新 main。
  • 显式检出并跟踪远端分支的语义正常。
  • 已有 feature/topic → origin/main 配置未经明确选择不会直接更新 main。
  • 有意配置异名 upstream 的用户仍能明确选择该目标,配置不会被静默改写。
  • 普通推送、分支菜单推送及“提交并推送”等入口一致,预览与实际目标一致。
  • 覆盖无 upstream、同名/异名 upstream、推送远端覆盖及预览后状态变化场景;检查新建 worktree 是否存在同类隐式跟踪问题。
  • 补充共享 Core 回归验证、两平台交互验证及对应功能矩阵记录。
Dominant language
TypeScript
Stars
1.8k
Forks
151
Avg merge
11h 27m
Merged PRs (30d)
310

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from 1lck/Lithe-IDEA

All issues in 1lck/Lithe-IDEA

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.