threads / discuss / 46716

Branch name support & character

Subject: Branch name support & character

## tl;dr

3 messages between Sep 7, 2017 and Sep 8, 2017.

replies: 2people: 3as markdown or json

夏大雨· Sep 7, 2017, 03:27 UTC · lore

I want to merge branch a to branch b so I rename branch b to a&b, but when I push a&b to remote repo, '&' is took as & operator for shell, and git push fails. So it would be better that branch name support & character for me.

Andrew Ardill· Sep 7, 2017, 05:31 UTC · re: 夏大雨 · lore

Re: Branch name support & character

Hi,
On 7 September 2017 at 13:27, 夏大雨 <xia.jason23@gmail.com> wrote:
> I want to merge branch a to branch b so I rename branch b to a&b, but
> when I push a&b to remote repo, '&' is took as & operator for shell,
> and git push fails. So it would be better that branch name support &
> character for me.
Have you tried quoting the branch name?

Using git checkout -b 'my&branch' works for me (single quotes around the branch name).

Pushing to a local remote also works: git push --set-upstream ../git-test-2 'my&branch'

That being said, I would advise not using & in branch names, specifically because it is a special character in shells.

Regards,
Andrew Ardill
Junio C Hamano· Sep 8, 2017, 01:18 UTC · re: Andrew Ardill · lore

Re: Branch name support & character

Andrew Ardill <andrew.ardill@gmail.com> writes:
Show 5 quoted lines
> Using git checkout -b 'my&branch' works for me (single quotes around
> the branch name).
>
> Pushing to a local remote also works: git push --set-upstream
> ../git-test-2 'my&branch'

Thanks for sanity-checking. I was wondering if we have codepaths that botch quoting (we shouldn't, and if there is, we should fix it).

>
> That being said, I would advise not using & in branch names,
> specifically because it is a special character in shells.
Good advice.

← back to recent threads