In Windows operating system, I clone a git warehouse with Git Bash. I use Git Bash to manipulate git branch and git branch -l, and find that they all list local branch names. When I manipulate git branch -h, it lists that -l, --list list branch names, but it doesn't mention that -l list local branches.
I'm confused whether their functions are same
Sometimes a table can make it easier to see.
| git branch | Shows local | Shows remote |
|---|---|---|
| x | ||
| -l or --list | x | |
| -r or --remote | x | |
| -a or --all | x | x |
So --list is the default you get if you only type git branch.
DESCRIPTION
If --list is given, or if there are no non-option arguments, existing branches are listed; the current branch will be highlighted in green and marked with an asterisk. Any branches checked out in linked worktrees will be highlighted in cyan and marked with a plus sign. Option -r causes the remote-tracking branches to be listed, and option -a shows both local and remote branches.
git-scm.com - git-branch
The git branch command is used to list, create, or delete branches. By default, it lists the names of all local branches in the repository. For example, running git branch without any additional options will display a list of all local branches:
$ git branch
Yourbranch1
Yourbranch2
The -l option is used to limit the list of branches to those that match a specified pattern. For example, running git branch -l "feat*" will list all branches that start with the prefix "feat"
$ git branch -l "feat*"
feat/feature1
feat/feature2
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