As title, I have read the manual but in vain.
What I found is that a *
can be wildcard pattern matching.
git branch --list 'issues*6' issues/586 issues/616
However, it's found by myself instead of mentioned in manual page.
I wonder what is the real format of <pattern>
.
The two primary branches in Git flow are main and develop. There are three types of supporting branches with different intended purposes: feature, release, and hotfix.
The git branch command lets you create, list, rename, and delete branches. It doesn't let you switch between branches or put a forked history back together again. For this reason, git branch is tightly integrated with the git checkout and git merge commands.
In Git, branches are commonly used in order to have a development separated from your main workflow. In software engineering teams, it is quite common to have a specific workflow implemented. You may choose for example to have one branch per major release or to have a branch in order to quickfix an issue.
How to list branches in Git? The command to list all branches in local and remote repositories is: $ git branch -a If you require only listing the remote branches from Git Bash then use this command:
Without -f, git branch refuses to change an existing branch. In combination with -d (or --delete ), allow deleting the branch irrespective of its merged status. In combination with -m (or --move ), allow renaming the branch even if the new branch name already exists, the same applies for -c (or --copy ).
When creating a new branch, set up branch.<name>.remote and branch.<name>.merge configuration entries to mark the start-point branch as "upstream" from the new branch. This configuration will tell git to show the relationship between the two branches in git status and git branch -v.
Using Git grep command for local branches examples For searching any committed tree, working directory etc. you may use the grep command of Git. The grep command is a big topic, however, in our context of showing branches, the command below shows how you may use it: $ git branch -a | grep -v ‘remotes’
Quoting from that same manual page you linked:
If
--list
is given, or if there are no non-option arguments, existing branches are listed; the current branch will be highlighted with an asterisk. Option-r
causes the remote-tracking branches to be listed, and option-a
shows both local and remote branches. If a<pattern>
is given, it is used as a shell wildcard to restrict the output to matching branches. If multiple patterns are given, a branch is shown if it matches any of the patterns. Note that when providing a<pattern>
, you must use--list
; otherwise the command is interpreted as branch creation.
So the answer, at least according to the documentation, is that "it is used as a shell wildcard". This assumes, of course, that you know what the phrase "shell wildcard" means—and more importantly, it's wrong, since a straight shell wildcard would not match across the /
.
The documentation should say something like: "The pattern acts much like a shell wildcard / glob pattern, except that slashes are not treated specially, so that a*b
matches both accb
and ac/cb
, and a[bc/]*
matches all of a/d
, abcd
, ac/cb
, and accb
."
Examples:
$ git branch -a a/d abcd ac/cb accb * master $ git branch --list 'a*b' ac/cb accb $ git branch --list 'a[bc/]*' a/d abcd ac/cb accb $
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With