[Bug][Windows/macOS] 从 origin/main 新建功能分支后,推送可能直接更新远端 main
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
问题
从 origin/main 新建并切换到异名功能分支(例如 feature/topic)后,Git 默认可能将其 upstream 自动配置为 origin/main。Lithe 推送时直接使用 upstream 分支名构造显式 refspec,导致功能分支提交可能直接更新远端 main。
影响 Windows 和 macOS:两平台相关创建分支及推送入口均调用同一 Rust Core 行为。Windows 有用户截图反馈;macOS 影响依据为源码调用链核对,尚未运行两平台完整 GUI 复现。隔离本地 Git 仓库已验证底层命令行为。用户使用的发行版本尚未确认。
复现
前提:远端允许更新 main,采用通常的 branch.autoSetupMerge=true,没有覆盖推送远端的特殊配置。
- Git 日志右键
origin/main,选择“从 origin/main 新建分支”。 - 输入
feature/topic并切换到该分支。 - 新建提交后,在 Lithe 中推送或使用“提交并推送”。
- 检查远端目标及 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。
- Core 创建分支:执行
switch -c <name> <reference>或branch <name> <reference>,未显式控制 tracking,远端起点受 Git 自动跟踪配置影响。 - Core 解析推送目标:选中的远端与 upstream 远端相同时,直接使用 upstream 分支名。
- Core 构造推送命令:显式指定源与目标 refspec,
push.default=simple异名保护不再生效。 - Windows 创建入口、创建 API、推送 API。
- macOS 创建分支适配、推送适配:均进入共享 Core 的
createBranch/push。
建议设计
- 区分“从远端分支派生功能分支”和“检出远端分支进行跟踪”。从
origin/main创建异名功能分支时,不隐式将源分支设为后续推送目标;首次默认发布到同名远端功能分支,成功后建立 upstream。 - 推送界面始终展示完整方向,如
feature/topic → origin/feature/topic,标明是否新建远端分支;成功结果也显示实际目标。 - 对已有异名 upstream,推送前要求明确选择“发布到同名远端分支(推荐)”或“继续推送到现有 upstream”。选择后者时按钮明确写出目标,如“推送到 main”。保留用户有意配置异名 upstream 的能力,不能静默改写。
- 普通同名分支推送不增加通用二次确认;异名目标通过明确选择解决,避免连续堆叠确认框。
- “提交并推送”走相同检查,尽量在提交前完成目标选择;实际推送保留预览后状态变化校验。
- 共享 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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from 1lck/Lithe-IDEA
-
area:editor bug P0 platform:macos review: low
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
1lck/Lithe-IDEA#1118 · 2 comments ·
Maintainers usually reply within 1 day
-
[Bug] 进程结束的显示逻辑不够合理Openarea:editor bug issue-form:bug P0 platform:macos review: medium
Difficulty 4/5 3-5 days Newbie friendliness 42/100
1lck/Lithe-IDEA#1344 ·
Maintainers usually reply within 1 day
-
[Bug] git显示问题Openarea:editor bug issue-form:bug P0 platform:macos review: medium
Difficulty 4/5 3-5 days Newbie friendliness 25/100
1lck/Lithe-IDEA#1342 ·
Maintainers usually reply within 1 day
-
area:project enhancement P2 platform:cross-platform review: medium
Difficulty 5/5 Over a week Newbie friendliness 35/100
1lck/Lithe-IDEA#1340 ·
Maintainers usually reply within 1 day
-
[Bug] Agent面板继续优化Possibly taken @xiaoyumuxi claimed this 2 days ago. Openarea:editor bug issue-form:bug P0 platform:macos review: medium
1lck/Lithe-IDEA#1315 · 1 comment · 1 assignee ·
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
ccch1mneyyy/dsh-TUI#1631 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
MiniMax-AI/minimax-code#507 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Transient OAuth login failure persists in getLoginStatus and masks active account in dashboardMay be free again A pull request for this issue was closed without being merged. Openaccount-pool bug gui
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
lidge-jun/opencodex#7378 · 2 comments ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day