git config_error ai_generated true

致命错误:名为'feature/new-ui'的分支已存在

fatal: A branch named 'feature/new-ui' already exists.

ID: git/rename-branch-conflict

其他格式: JSON · Markdown 中文 · English
80%修复率
83%置信度
1证据数
2023-11-20首次发现

版本兼容性

版本状态引入弃用备注
git 2.42.0 active
git 2.43.0 active
git 2.44.0 active

根因分析

尝试创建或重命名分支到已存在的分支名称

English

Attempting to create or rename a branch to a name that already exists in the repository.

generic

官方文档

https://git-scm.com/docs/git-branch

解决方案

  1. Delete the existing branch first if safe: git branch -D feature/new-ui && git branch -m old-name feature/new-ui
  2. Force push the renamed branch after local rename: git push origin --delete feature/new-ui && git push origin feature/new-ui

无效尝试

常见但无效的做法:

  1. Using 'git branch -m old new' when 'new' already exists on remote 80% 失败

    Local rename does not check remote; push will fail with non-fast-forward

  2. Deleting the local branch with 'git branch -D new' then trying to rename 70% 失败

    Remote branch still exists; push will still fail