This is an old revision of the document!
Overview
Some trickier operations involving branches.
Types of branches
bugfix: local branch, for personal use onlymaster: local tracking branchorigin/master: remote tracking branch (in your object store)masteron remote (upstream) machine: remote branch
Displaying
Non-verbosely
$ git branch dev_pdev emergency failed fix flags kerneldoc makefile * master mdio nb net_phy_kconfig of watchog $
Verbosely
$ git branch -v dev_pdev c4c5cbc5de95 platform.c: standardize on drv/pdrv, dev/pdev names emergency 894025f24bd0 Merge tag 'usb-4.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb failed 99bd7aaa5563 [PATCH] "failed" -> "fail" in some dts files fix 5d1d2d55459b second part of fix flags 051935978432 Merge branch 'for-4.19' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata kerneldoc 7201de85450d [PATCH] drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c: misspelled "dev" makefile db5941a490b1 makefile * master 3a5af36b6d0e Merge tag '4.19-rc3-smb3-cifs' of git://git.samba.org/sfrench/cifs-2.6 mdio 1397529bc401 phy: Refactor include/uapi/linux/mdio.h nb 0b07194bb55e Linux 4.14-rc7 net_phy_kconfig 2a93d87ebb56 aesthetic fixes to drivers/net/phy/Kconfig of b4e0cbfd71d3 Remove all remaining tests and usages of "chosen@0". watchog d2b752464917 watchdog: fix a small number of "watchog" typos in comments $
Really, really verbosely
Additionally, print the name of the upstream branch (if there is one):
$ git branch -v -v (or -vv) ... snip ... * master 3a5af36b6d0e [origin/master] Merge tag '4.19-rc3-smb3-cifs' of git://git.samba.org/sfrench/cifs-2.6 ... snip ...
What's merged and what isn't
What is merged (into current branch or specified branch):
$ git branch --merged emergency flags * master nb $
$ git branch --merged nb nb $
What isn't merged:
$ git branch --no-merged dev_pdev failed fix kerneldoc makefile mdio net_phy_kconfig of watchog $
Which branches contain (or don't contain) a commit?
$ git branch --contains v4.14 b1 b2 dev_pdev failed flags kerneldoc * master mdio net_phy_kconfig watchog $
Conversely:
$ git branch --no-contains <commit>