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.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

How Linux Works, 2nd Edition

How Linux Works, 2nd Edition

Brian Ward

Publisher Resources

ISBN: 9780596806088Errata Page