1 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.1//EN"
2 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3 <html xmlns=
"http://www.w3.org/1999/xhtml" xml:
lang=
"en">
5 <meta http-equiv=
"Content-Type" content=
"text/html; charset=UTF-8" />
6 <meta name=
"generator" content=
"AsciiDoc 8.2.5" />
7 <style type=
"text/css">
9 p
, li
, dt
, dd
, div
, pre
, h1
, h2
, h3
, h4
, h5
, h6
{
11 border: 1px solid red;
16 margin: 1em 5% 1em 5%;
21 text-decoration: underline
;
39 h1
, h2
, h3
, h4
, h5
, h6
{
41 font-family: sans-serif
;
48 border-bottom: 2px solid silver
;
66 border: 1px solid silver
;
81 font-family: sans-serif
;
88 font-family: sans-serif
;
92 font-family: sans-serif
;
94 border-top: 2px solid silver
;
100 padding-bottom: 0.5em;
104 padding-bottom: 0.5em;
108 div
.tableblock
, div
.imageblock
, div
.exampleblock
, div
.verseblock
,
109 div
.quoteblock
, div
.literalblock
, div
.listingblock
, div
.sidebarblock
,
110 div
.admonitionblock
{
113 margin-bottom: 1.5em;
115 div
.admonitionblock
{
117 margin-bottom: 2.5em;
120 div
.content
{ /* Block element content. */
124 /* Block element titles. */
125 div
.title
, caption
.title
{
126 font-family: sans-serif
;
130 margin-bottom: 0.5em;
136 td div
.title:first-child
{
139 div
.content div
.title:first-child
{
142 div
.content
+ div
.title
{
146 div
.sidebarblock
> div
.content
{
148 border: 1px solid silver
;
155 div
.listingblock
> div
.content
{
156 border: 1px solid silver
;
161 div
.quoteblock
> div
.content
{
168 div
.verseblock
+ div
.attribution
{
172 div
.admonitionblock
.icon
{
176 text-decoration: underline
;
178 padding-right: 0.5em;
180 div
.admonitionblock td
.content
{
182 border-left: 2px solid silver
;
185 div
.exampleblock
> div
.content
{
186 border-left: 2px solid silver
;
190 div
.verseblock div
.content
{
194 div
.imageblock div
.content
{ padding-left: 0; }
195 div
.imageblock img
{ border: 1px solid silver
; }
196 span
.image img
{ border-style: none
; }
200 margin-bottom: 0.8em;
212 list-style-position: outside
;
215 list-style-type: lower-alpha
;
218 div
.tableblock
> table
{
219 border: 3px solid
#527bbd;
222 font-family: sans-serif
;
231 margin-bottom: 0.8em;
239 padding-right: 0.8em;
246 div#footer-badges
{ display: none
; }
251 font-family: sans-serif
;
255 margin-bottom: 0.1em;
258 div
.toclevel1
, div
.toclevel2
, div
.toclevel3
, div
.toclevel4
{
274 include1::./stylesheets
/xhtml11-manpage
.css
[]
275 /* Workarounds for IE6's broken and incomplete CSS2. */
277 div
.sidebar-content
{
279 border: 1px solid silver
;
282 div
.sidebar-title
, div
.image-title
{
283 font-family: sans-serif
;
286 margin-bottom: 0.5em;
289 div
.listingblock div
.content
{
290 border: 1px solid silver
;
295 div
.quoteblock-content
{
299 div
.exampleblock-content
{
300 border-left: 2px solid silver
;
304 /* IE6 sets dynamically generated links as visited. */
305 div#toc
a:visited
{ color: blue
; }
307 <title>git-branch(
1)
</title>
312 git-branch(
1) Manual Page
315 <div class=
"sectionbody">
317 List, create, or delete branches
322 <div class=
"sectionbody">
323 <div class=
"verseblock">
324 <div class=
"content"><em>git branch
</em> [--color[=
<when
>] | --no-color] [-r | -a]
325 [-v [--abbrev=
<length
> | --no-abbrev]]
326 [(--merged | --no-merged | --contains) [
<commit
>]]
327 <em>git branch
</em> [--set-upstream | --track | --no-track] [-l] [-f]
<branchname
> [
<start-point
>]
328 <em>git branch
</em> (-m | -M) [
<oldbranch
>]
<newbranch
>
329 <em>git branch
</em> (-d | -D) [-r]
<branchname
>…</div></div>
331 <h2 id=
"_description">DESCRIPTION
</h2>
332 <div class=
"sectionbody">
333 <div class=
"para"><p>With no arguments, existing branches are listed and the current branch will
334 be highlighted with an asterisk. Option
<tt>-r
</tt> causes the remote-tracking
335 branches to be listed, and option
<tt>-a
</tt> shows both.
</p></div>
336 <div class=
"para"><p>With
<tt>--contains
</tt>, shows only the branches that contain the named commit
337 (in other words, the branches whose tip commits are descendants of the
338 named commit). With
<tt>--merged
</tt>, only branches merged into the named
339 commit (i.e. the branches whose tip commits are reachable from the named
340 commit) will be listed. With
<tt>--no-merged
</tt> only branches not merged into
341 the named commit will be listed. If the
<commit
> argument is missing it
342 defaults to
<em>HEAD
</em> (i.e. the tip of the current branch).
</p></div>
343 <div class=
"para"><p>The command's second form creates a new branch head named
<branchname
>
344 which points to the current
<em>HEAD
</em>, or
<start-point
> if given.
</p></div>
345 <div class=
"para"><p>Note that this will create the new branch, but it will not switch the
346 working tree to it; use
"git checkout <newbranch>" to switch to the
347 new branch.
</p></div>
348 <div class=
"para"><p>When a local branch is started off a remote branch, git sets up the
349 branch so that
<em>git pull
</em> will appropriately merge from
350 the remote branch. This behavior may be changed via the global
351 <tt>branch.autosetupmerge
</tt> configuration flag. That setting can be
352 overridden by using the
<tt>--track
</tt> and
<tt>--no-track
</tt> options.
</p></div>
353 <div class=
"para"><p>With a
<em>-m
</em> or
<em>-M
</em> option,
<oldbranch
> will be renamed to
<newbranch
>.
354 If
<oldbranch
> had a corresponding reflog, it is renamed to match
355 <newbranch
>, and a reflog entry is created to remember the branch
356 renaming. If
<newbranch
> exists, -M must be used to force the rename
358 <div class=
"para"><p>With a
<tt>-d
</tt> or
<tt>-D
</tt> option,
<tt><branchname
></tt> will be deleted. You may
359 specify more than one branch for deletion. If the branch currently
360 has a reflog then the reflog will also be deleted.
</p></div>
361 <div class=
"para"><p>Use -r together with -d to delete remote-tracking branches. Note, that it
362 only makes sense to delete remote-tracking branches if they no longer exist
363 in the remote repository or if
<em>git fetch
</em> was configured not to fetch
364 them again. See also the
<em>prune
</em> subcommand of
<a href=
"git-remote.html">git-remote(
1)
</a> for a
365 way to clean up all obsolete remote-tracking branches.
</p></div>
367 <h2 id=
"_options">OPTIONS
</h2>
368 <div class=
"sectionbody">
369 <div class=
"vlist"><dl>
375 Delete a branch. The branch must be fully merged in HEAD.
383 Delete a branch irrespective of its merged status.
391 Create the branch's reflog. This activates recording of
392 all changes made to the branch ref, enabling use of date
393 based sha1 expressions such as
"<branchname>@{yesterday}".
404 Reset
<branchname
> to
<startpoint
> if
<branchname
> exists
405 already. Without
<tt>-f
</tt> <em>git branch
</em> refuses to change an existing branch.
413 Move/rename a branch and the corresponding reflog.
421 Move/rename a branch even if the new branch name already exists.
425 --color[=
<when
>]
429 Color branches to highlight current, local, and remote branches.
430 The value must be always (the default), never, or auto.
438 Turn off branch colors, even when the configuration file gives the
439 default to color output.
440 Same as
<tt>--color=never
</tt>.
448 List or delete (if used with -d) the remote-tracking branches.
456 List both remote-tracking branches and local branches.
467 Show sha1 and commit subject line for each head, along with
468 relationship to upstream branch (if any). If given twice, print
469 the name of the upstream branch, as well.
473 --abbrev=
<length
>
477 Alter the sha1's minimum display length in the output listing.
478 The default value is
7.
486 Display the full sha1s in the output listing rather than abbreviating them.
497 When creating a new branch, set up configuration to mark the
498 start-point branch as
"upstream" from the new branch. This
499 configuration will tell git to show the relationship between the
500 two branches in
<tt>git status
</tt> and
<tt>git branch -v
</tt>. Furthermore,
501 it directs
<tt>git pull
</tt> without arguments to pull from the
502 upstream when the new branch is checked out.
504 <div class=
"para"><p>This behavior is the default when the start point is a remote branch.
505 Set the branch.autosetupmerge configuration variable to
<tt>false
</tt> if you
506 want
<tt>git checkout
</tt> and
<tt>git branch
</tt> to always behave as if
<em>--no-track
</em>
507 were given. Set it to
<tt>always
</tt> if you want this behavior when the
508 start-point is either a local or remote branch.
</p></div>
515 Do not set up
"upstream" configuration, even if the
516 branch.autosetupmerge configuration variable is true.
524 If specified branch does not exist yet or if
<em>--force
</em> has been
525 given, acts exactly like
<em>--track
</em>. Otherwise sets up configuration
526 like
<em>--track
</em> would when creating the branch, except that where
527 branch points to is not changed.
531 --contains
<commit
>
535 Only list branches which contain the specified commit.
539 --merged [
<commit
>]
543 Only list branches whose tips are reachable from the
544 specified commit (HEAD if not specified).
548 --no-merged [
<commit
>]
552 Only list branches whose tips are not reachable from the
553 specified commit (HEAD if not specified).
561 The name of the branch to create or delete.
562 The new branch name must pass all checks defined by
563 <a href=
"git-check-ref-format.html">git-check-ref-format(
1)
</a>. Some of these checks
564 may restrict the characters allowed in a branch name.
572 The new branch head will point to this commit. It may be
573 given as a branch name, a commit-id, or a tag. If this
574 option is omitted, the current HEAD will be used instead.
582 The name of an existing branch to rename.
590 The new name for an existing branch. The same restrictions as for
591 <branchname
> apply.
596 <h2 id=
"_examples">Examples
</h2>
597 <div class=
"sectionbody">
598 <div class=
"vlist"><dl>
600 Start development from a known tag
603 <div class=
"listingblock">
604 <div class=
"content">
605 <pre><tt>$ git clone git://git.kernel.org/pub/scm/.../linux-
2.6 my2.6
607 $ git branch my2.6
.14 v2.6
.14 <b>(
1)
</b>
608 $ git checkout my2.6
.14</tt></pre>
610 <div class=
"colist"><ol>
613 This step and the next one could be combined into a single step with
614 "checkout -b my2.6.14 v2.6.14".
620 Delete an unneeded branch
623 <div class=
"listingblock">
624 <div class=
"content">
625 <pre><tt>$ git clone git://git.kernel.org/.../git.git my.git
627 $ git branch -d -r origin/todo origin/html origin/man
<b>(
1)
</b>
628 $ git branch -D test
<b>(
2)
</b></tt></pre>
630 <div class=
"colist"><ol>
633 Delete the remote-tracking branches
"todo",
"html" and
"man". The next
634 <em>fetch
</em> or
<em>pull
</em> will create them again unless you configure them not to.
635 See
<a href=
"git-fetch.html">git-fetch(
1)
</a>.
640 Delete the
"test" branch even if the
"master" branch (or whichever branch
641 is currently checked out) does not have all commits from the test branch.
648 <h2 id=
"_notes">Notes
</h2>
649 <div class=
"sectionbody">
650 <div class=
"para"><p>If you are creating a branch that you want to checkout immediately, it is
651 easier to use the git checkout command with its
<tt>-b
</tt> option to create
652 a branch and check it out with a single command.
</p></div>
653 <div class=
"para"><p>The options
<tt>--contains
</tt>,
<tt>--merged
</tt> and
<tt>--no-merged
</tt> serve three related
654 but different purposes:
</p></div>
655 <div class=
"ilist"><ul>
658 <tt>--contains
<commit
></tt> is used to find all branches which will need
659 special attention if
<commit
> were to be rebased or amended, since those
660 branches contain the specified
<commit
>.
665 <tt>--merged
</tt> is used to find all branches which can be safely deleted,
666 since those branches are fully contained by HEAD.
671 <tt>--no-merged
</tt> is used to find branches which are candidates for merging
672 into HEAD, since those branches are not fully contained by HEAD.
677 <h2 id=
"_see_also">SEE ALSO
</h2>
678 <div class=
"sectionbody">
679 <div class=
"para"><p><a href=
"git-check-ref-format.html">git-check-ref-format(
1)
</a>,
680 <a href=
"git-fetch.html">git-fetch(
1)
</a>,
681 <a href=
"git-remote.html">git-remote(
1)
</a>,
682 <a href=
"user-manual.html#what-is-a-branch">“Understanding history: What is
683 a branch?
”</a> in the Git User's Manual.
</p></div>
685 <h2 id=
"_author">Author
</h2>
686 <div class=
"sectionbody">
687 <div class=
"para"><p>Written by Linus Torvalds
<torvalds@osdl.org
> and Junio C Hamano
<gitster@pobox.com
></p></div>
689 <h2 id=
"_documentation">Documentation
</h2>
690 <div class=
"sectionbody">
691 <div class=
"para"><p>Documentation by Junio C Hamano and the git-list
<git@vger.kernel.org
>.
</p></div>
693 <h2 id=
"_git">GIT
</h2>
694 <div class=
"sectionbody">
695 <div class=
"para"><p>Part of the
<a href=
"git.html">git(
1)
</a> suite
</p></div>
698 <div id=
"footer-text">
699 Last updated
2010-
03-
03 05:
12:
39 UTC