@@ -8,12 +8,15 @@ git-branch - List, create, or delete branches
8
8
SYNOPSIS
9
9
--------
10
10
[verse]
11
- 'git branch' [--color[=<when>] | --no-color] [-r | -a]
12
- [--list] [--show-current] [-v [--abbrev=<length> | --no-abbrev]]
11
+ 'git branch' [--color[=<when>] | --no-color]
12
+ [-v [--abbrev=<length> | --no-abbrev]]
13
+ [--show-current]
13
14
[--column[=<options>] | --no-column] [--sort=<key>]
14
15
[(--merged | --no-merged) [<commit>]]
15
16
[--contains [<commit]] [--no-contains [<commit>]]
16
- [--points-at <object>] [--format=<format>] [<pattern>...]
17
+ [--points-at <object>] [--format=<format>]
18
+ [(-r | --remotes) | (-a | --all)]
19
+ [--list] [<pattern>...]
17
20
'git branch' [--track | --no-track] [-f] <branchname> [<start-point>]
18
21
'git branch' (--set-upstream-to=<upstream> | -u <upstream>) [<branchname>]
19
22
'git branch' --unset-upstream [<branchname>]
@@ -28,11 +31,15 @@ DESCRIPTION
28
31
If `--list` is given, or if there are no non-option arguments, existing
29
32
branches are listed; the current branch will be highlighted with an
30
33
asterisk. Option `-r` causes the remote-tracking branches to be listed,
31
- and option `-a` shows both local and remote branches. If a `<pattern>`
34
+ and option `-a` shows both local and remote branches.
35
+
36
+ If a `<pattern>`
32
37
is given, it is used as a shell wildcard to restrict the output to
33
38
matching branches. If multiple patterns are given, a branch is shown if
34
- it matches any of the patterns. Note that when providing a
35
- `<pattern>`, you must use `--list`; otherwise the command is interpreted
39
+ it matches any of the patterns.
40
+
41
+ Note that when providing a
42
+ `<pattern>`, you must use `--list`; otherwise the command may be interpreted
36
43
as branch creation.
37
44
38
45
With `--contains`, shows only the branches that contain the named commit
@@ -153,10 +160,12 @@ This option is only applicable in non-verbose mode.
153
160
-r::
154
161
--remotes::
155
162
List or delete (if used with -d) the remote-tracking branches.
163
+ Combine with `--list` to match the optional pattern(s).
156
164
157
165
-a::
158
166
--all::
159
167
List both remote-tracking branches and local branches.
168
+ Combine with `--list` to match optional pattern(s).
160
169
161
170
-l::
162
171
--list::
@@ -322,6 +331,18 @@ $ git branch -D test <2>
322
331
<2> Delete the "test" branch even if the "master" branch (or whichever branch
323
332
is currently checked out) does not have all commits from the test branch.
324
333
334
+ Listing branches from a specific remote::
335
+ +
336
+ ------------
337
+ $ git branch -r -l '<remote>/<pattern>' <1>
338
+ $ git for-each-ref 'refs/remotes/<remote>/<pattern>' <2>
339
+ ------------
340
+ +
341
+ <1> Using `-a` would conflate <remote> with any local branches you happen to
342
+ have been prefixed with the same <remote> pattern.
343
+ <2> `for-each-ref` can take a wide range of options. See linkgit:git-for-each-ref[1]
344
+
345
+ Patterns will normally need quoting.
325
346
326
347
NOTES
327
348
-----
0 commit comments