Set Upstream | git branch -u origin/master |
git branch --set-upstream my_branch origin/my_branch |
|
Delete (local) | git branch -d <branch_name> |
git branch -D <branch_name> |
|
Delete (remote) | git push --delete <remote_name> <branch_name> |
List Upstream | git rev-parse --abbrev-ref master@{upstream} |
git branch -vv |
|
Rename (current) | git branch -m <new-name> |
Rename (other) | git branch -m <old-name> <new-name> |
git branch [--color[=<when>] | --no-color] [--show-current]
[-v [--abbrev=<length> | --no-abbrev]]
[--column[=<options>] | --no-column] [--sort=<key>]
[--merged [<commit>]] [--no-merged [<commit>]]
[--contains [<commit>]] [--no-contains [<commit>]]
[--points-at <object>] [--format=<format>]
[(-r | --remotes) | (-a | --all)]
[--list] [<pattern>…]
git branch [--track | --no-track] [-f] <branchname> [<start-point>]
git branch (--set-upstream-to=<upstream> | -u <upstream>) [<branchname>]
git branch --unset-upstream [<branchname>]
git branch (-m | -M) [<oldbranch>] <newbranch>
git branch (-c | -C) [<oldbranch>] <newbranch>
git branch (-d | -D) [-r] <branchname>…
git branch --edit-description [<branchname>]
Docs instruct using https://git-scm.com/docs/git-for-each-ref#_field_names for field names.
Name and commit
git branch --format=="%(objectname) %(refname)"
git branch --format=="%(objectname:short) %(refname:short)"
Name and commit for specific branch:
git branch --list dev --format "%(objectname:short) %(refname:short)"