Note that:
git branch --list
, by default, lists local branches, not remote ones (git branch -r
): you can create local branches after those remote ones in order to "see other branches".
git branch -l
only lists local branches as a side-effect:
It is not the same as git branch --list
, and '-l
' will be deprecated with Git 2.19 (Q3 2019).
The "-l
" option in "git branch -l
" is an unfortunate short-hand for
"--create-reflog
", but many users, both old and new, somehow expect
it to be something else, perhaps "--list
".
This step warns when "-l
" is used as a short-hand for "--create-reflog
" and warns about the future repurposing of the it when it is used.
See commit 055930b, commit 7687f19, commit 6b15595 (22 Jun 2018) by Jeff King (peff
).
(Merged by Junio C Hamano -- gitster
-- in commit d18602f, 18 Jul 2018)
branch
: deprecate "-l
" option
The "-l
" option is short for "--create-reflog
". This has caused much confusion over the years.
Most people expect it to work as "--list
", because that would match the other
"mode" options like -d
/--delete
and -m
/--move
, as well as
the similar -l
/--list
option of git-tag
.
Adding to the confusion, using "-l
" appears to work as "--list
" in some cases:
$ git branch -l
* master
because the branch command defaults to listing (so even trying to specify --list
in the command above is redundant).
But that may bite the user later when they add a pattern, like:
$ git branch -l foo
which does not return an empty list, but in fact creates a
new branch (with a reflog, naturally) called "foo".
It's also probably quite uncommon for people to actually use "-l
" to create a reflog. Since 0bee591 (Enable reflogs by default in any repository with a working directory., 2006-12-14 Git v1.5.0), this is the default in non-bare repositories.
So it's rather unfortunate that the feature squats on the short-and-sweet "-l
" (which was only added in 3a4b3f2 (Create/delete branch ref logs., 2006-05-19, Git v1.4.0), meaning there were only 7 months where it was actually useful).
Let's deprecate "-l
" in hopes of eventually re-purposing it to "--list
".
With Git 2.20 (Q2 2018), -l
is officially short for --list
.
See commit 94a1380 (30 Aug 2018), and commit a15d598 (22 Jun 2018) by Jeff King (peff
).
(Merged by Junio C Hamano -- gitster
-- in commit 7dc341c, 17 Sep 2018)