# Branch name support & character

3 messages from 2017-09-07 to 2017-09-08. Participants: 夏大雨, Andrew Ardill, Junio C Hamano.
Thread: https://gitlist.dev/t/46716

## 夏大雨, 2017-09-07 03:27

Subject: Branch name support & character
Message-ID: <CA+zMtjmhrE54=ke6vVDGOcrbHkdPuE-Gf5cwQEp8LL2h+xen0g@mail.gmail.com>
URL: https://gitlist.dev/e/CA%2BzMtjmhrE54%3Dke6vVDGOcrbHkdPuE-Gf5cwQEp8LL2h%2Bxen0g%40mail.gmail.com

```
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, 2017-09-07 05:31

Subject: Re: Branch name support & character
Message-ID: <CAH5451m9asxzaOEzQ2Jjk9Ly97GVnb7DV0uZS=96B=yHCYLWCw@mail.gmail.com>
URL: https://gitlist.dev/e/CAH5451m9asxzaOEzQ2Jjk9Ly97GVnb7DV0uZS%3D96B%3DyHCYLWCw%40mail.gmail.com
In-Reply-To: <CA+zMtjmhrE54=ke6vVDGOcrbHkdPuE-Gf5cwQEp8LL2h+xen0g@mail.gmail.com>

```
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, 2017-09-08 01:18

Subject: Re: Branch name support & character
Message-ID: <xmqqk21a0yzi.fsf@gitster.mtv.corp.google.com>
URL: https://gitlist.dev/e/xmqqk21a0yzi.fsf%40gitster.mtv.corp.google.com
In-Reply-To: <CAH5451m9asxzaOEzQ2Jjk9Ly97GVnb7DV0uZS=96B=yHCYLWCw@mail.gmail.com>

```
Andrew Ardill <andrew.ardill@gmail.com> writes:

> 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.


```
