Robert Sim
Robert Sim

Reputation: 1560

git branch naming on Windows

When I execute the command git checkout -b /dev/myfeature in Windows, git bash returns with this error: fatal: 'C:/Program Files/Git/dev/myfeature' is not a valid branch name.

What am I doing wrong?

Upvotes: 0

Views: 234

Answers (2)

Witnessthis
Witnessthis

Reputation: 136

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

The name of the branch to create or delete. The new branch name must pass all checks defined by git-check-ref-format[1]. Some of these checks may restrict the characters allowed in a branch name.

And from https://git-scm.com/docs/git-check-ref-format:

They cannot begin or end with a slash / or contain multiple consecutive slashes (see the --normalize option below for an exception to this rule)

Hope this helps

Upvotes: 5

kah608
kah608

Reputation: 565

I'm not 100% sure here, but I suspect the leading "/" This is similar to this question Which characters are illegal within a branch name?

Which has a trailing "/" in the list... so I'm suspicious of the leading slash

Upvotes: 3

Related Questions