threads / discuss / 56082

git checkout -b refs/master origin/master

Subject: git checkout -b refs/master origin/master

## tl;dr

2 messages between Jul 9, 2021 and Jul 9, 2021.

replies: 1people: 2as markdown or json

Martin· Jul 9, 2021, 12:40 UTC · lore
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· Jul 9, 2021, 14:56 UTC · re: Martin · lore

RE: git checkout -b refs/master origin/master

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

← back to recent threads