Skip to Content
Linux in a Nutshell, 6th Edition
book

Linux in a Nutshell, 6th Edition

by Ellen Siever, Stephen Figgins, Robert Love, Arnold Robbins
September 2009
Beginner
942 pages
85h 34m
English
O'Reilly Media, Inc.
Content preview from Linux in a Nutshell, 6th Edition

Name

branch

Synopsis

git branch [-r] [-a] [--contains commit]
git branch [-f] [--track] branchname [commit]
git branch -m oldname newname
git branch -d|-D [-r] branchname

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.

Tip

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 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Unix in a Nutshell, 4th Edition

Unix in a Nutshell, 4th Edition

Arnold Robbins
Linux Under the Hood

Linux Under the Hood

Sander van Vugt
Linux Kernel in a Nutshell

Linux Kernel in a Nutshell

Greg Kroah-Hartman

Publisher Resources

ISBN: 9780596806088Errata Page