Reputation: 163
This one
git checkout -b #1-my-awesome-feature
creates error
error: switch `b' requires a value
escaping it with backslash or wrapping it in quotes will work
git checkout -b \#1-my-awesome-feature
but strange enough this
git branch #1-my-awesome-feature
will not produce any error and if you check if it is created with
git branch --all
there is no branch.
If hash char is not in the first position of the branch name, branch will be created.
git branch feature-#1
Executing git branch
feature-#1
* master
So my question is how hash (#) char is 'translated' in terminal and why it is not working when it is at first place?
Thanks!
Upvotes: 13
Views: 7897
Reputation: 2654
#
means a comment is starting (atleast in a linux shell). So
git checkout -b #1-my-awesome-feature
becomes:
git checkout -b
and throws error that b
option requires a value.
As shown here, you can solve this by escaping the #
with a \
or by putting the name in single/double quotes:
git checkout -b \#1-my-awesome-feature
git checkout -b "#1-my-awesome-feature"
git checkout -b '#1-my-awesome-feature'
Upvotes: 29