git
config_error
ai_generated
true
fatal: A branch named 'feature/new-ui' already exists.
ID: git/rename-branch-conflict
80%Fix Rate
83%Confidence
1Evidence
2023-11-20First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| git 2.42.0 | active | — | — | — |
| git 2.43.0 | active | — | — | — |
| git 2.44.0 | active | — | — | — |
Root Cause
Attempting to create or rename a branch to a name that already exists in the repository.
generic中文
尝试创建或重命名分支到已存在的分支名称
Official Documentation
https://git-scm.com/docs/git-branchWorkarounds
-
85% success Delete the existing branch first if safe: git branch -D feature/new-ui && git branch -m old-name feature/new-ui
Delete the existing branch first if safe: git branch -D feature/new-ui && git branch -m old-name feature/new-ui
-
75% success Force push the renamed branch after local rename: git push origin --delete feature/new-ui && git push origin feature/new-ui
Force push the renamed branch after local rename: git push origin --delete feature/new-ui && git push origin feature/new-ui
中文步骤
Delete the existing branch first if safe: git branch -D feature/new-ui && git branch -m old-name feature/new-ui
Force push the renamed branch after local rename: git push origin --delete feature/new-ui && git push origin feature/new-ui
Dead Ends
Common approaches that don't work:
-
Using 'git branch -m old new' when 'new' already exists on remote
80% fail
Local rename does not check remote; push will fail with non-fast-forward
-
Deleting the local branch with 'git branch -D new' then trying to rename
70% fail
Remote branch still exists; push will still fail