Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: unrecognised branch name

In git, I named a branch: parse()

The name has been accepted, but when merging I get the error:

git merge parse() bash: syntax error near unexpected token '('

Is it possible to rename a branch? Are there other ways to fix this problem?

Thank you!

Platform: Linux, bash

like image 208
Pietro Avatar asked Dec 17 '22 00:12

Pietro


2 Answers

Try merging by putting quotes around the branch name instead, e.g.:

git merge 'parse()'

You can rename a branch, but it's not so straightforward. Wherever you want to use the branch name, just use quotes (single or double!).

like image 157
Asherah Avatar answered Dec 19 '22 06:12

Asherah


You can rename a branch using :

git branch -m 'parse()' your_new_branch_name

(see Switch branch names in git)

You should also note that using parenthesis in branch names (or any special bash character) will only cause you problems. I would recommend using only [-_a-zA-Z0-9] characters.

like image 26
Vincent B. Avatar answered Dec 19 '22 06:12

Vincent B.