Improve error message when branch creation fails due to naming conflicts
Proposal
When attempting to create a branch with a hierarchical name (e.g., release/123) while a parent branch (e.g., release) already exists, GitLab displays a misleading error message: Failed to create branch 'release/123': invalid reference name 'main'.
This error incorrectly suggests the problem is with the 'main' branch, when the actual issue is a Git limitation regarding branch naming conflicts.
A clear, informative error message should be raised instead like:
Cannot create branch 'release/123' because branch 'release' already exists.
Git does not allow a branch to be both a file and a directory.
Recreation
- Create a new project.
- Create a new branch from
mainnamedrelease. - Create a new branch from
mainnamedrelease/123. - Observed this error message.
Failed to create branch 'release/123': invalid reference name 'main'
Edited by 🤖 GitLab Bot 🤖