git branch [-r] [-a] [--contains
commit] git branch [-f] [--track]
commit] git branch -m
oldname newnamegit branch -d|-D [-r]
List, create, rename, and delete branches.
- git branch [-r] [-a] [--contains commit]
List the existing branches. By default, lists only local branches (.git/refs/heads/*). With -r, list remote tracking branches instead (.git/refs/remotes/*/*). With -a, list all local and remote tracking branches. With --contains, list only the branches that contain the given commit.
- git branch [-f] [--track|--no-track] branchname [commit]
Create a new branch, branchname, that points at the given commit. The default for commit is HEAD. If branchname already exists, the operation will fail unless -f is specified. If you specify --track (the default in newer versions of Git) and commit is a remote tracking branch, you will be able to type simply git merge or git pull in the future to merge remote changes into your branch.
This command does not check out your new branch. If you want to create a new branch and check it out in one step, use git checkout -b.
- git branch -m|-Moldnamenewname
Rename a branch from oldname to newname. If newname already exists, -m will fail while -M will overwrite it.
- git branch -d|-D [-r]branchname
Delete branchname. If -r is specified, branchname is a remote tracking branch (.git/refs/remotes/*/*); otherwise it is a local branch (.git/refs/heads/*). If you use -d, the branch will only be deleted if your current HEAD ...