# git checkout -b refs/master origin/master

2 messages from 2021-07-09 to 2021-07-09. Participants: Martin, Felipe Contreras.
Thread: https://gitlist.dev/t/56082

## Martin, 2021-07-09 12:40

Subject: git checkout -b refs/master origin/master
Message-ID: <71d3662c-411b-88aa-5cfc-b2f86a067507@mfriebe.de>
URL: https://gitlist.dev/e/71d3662c-411b-88aa-5cfc-b2f86a067507%40mfriebe.de

```
Just curious..

"refs/master" is allowed as local branch name (git checkout / git branch 
/ git switch)

Is that intentionally allowed?

  git for-each-ref
6faf346455d0a024cb1edf2d64fc4c42b450c53d commit refs/heads/refs/master

  git for-each-ref --format="ref=%(refname)"
ref=refs/heads/refs/master

Especially the effect on
git for-each-ref --format="ref=%(refname:lstrip=-1)"
master

You only get part of the branch name.
Because "lstrip" does not distinguish between the / as separator in the 
refs, and the "/" as part of the name.

```

## Felipe Contreras, 2021-07-09 14:56

Subject: RE: git checkout -b refs/master origin/master
Message-ID: <60e8639b87a83_226420859@natae.notmuch>
URL: https://gitlist.dev/e/60e8639b87a83_226420859%40natae.notmuch
In-Reply-To: <71d3662c-411b-88aa-5cfc-b2f86a067507@mfriebe.de>

```
Martin wrote:
> Especially the effect on
> git for-each-ref --format="ref=%(refname:lstrip=-1)"
> master

It's probably better to do refname:lstrip=2.

> You only get part of the branch name.
> Because "lstrip" does not distinguish between the / as separator in the 
> refs, and the "/" as part of the name.

That shouldn't matter. I use 'fc/area/topic' as names of my branches,
and I know Junio uses similar names: '<contributor>/topic'.

-- 
Felipe Contreras

```
