<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sect2 SYSTEM "../../../dtd/dblite.dtd">

<sect2 lang="en" id="git-branch(1)">
    <title>git-branch(1)</title>
    <date>2024-07-02</date>
<revhistory><revision><date>2024-07-02</date></revision></revhistory>
<indexterm>
<primary>git-branch(1)</primary>
</indexterm>
<simplesect id="git-branch(1)__name">
<title>NAME</title>
<simpara>git-branch - List, create, or delete branches</simpara>
</simplesect>
<simplesect id="git-branch(1)__synopsis">
<title>SYNOPSIS</title>
<blockquote>
<literallayout><emphasis>git branch</emphasis> [--color[=&lt;when&gt;] | --no-color] [--show-current]
        [-v [--abbrev=&lt;n&gt; | --no-abbrev]]
        [--column[=&lt;options&gt;] | --no-column] [--sort=&lt;key&gt;]
        [--merged [&lt;commit&gt;]] [--no-merged [&lt;commit&gt;]]
        [--contains [&lt;commit&gt;]] [--no-contains [&lt;commit&gt;]]
        [--points-at &lt;object&gt;] [--format=&lt;format&gt;]
        [(-r | --remotes) | (-a | --all)]
        [--list] [&lt;pattern&gt;&#8230;]
<emphasis>git branch</emphasis> [--track[=(direct|inherit)] | --no-track] [-f]
        [--recurse-submodules] &lt;branchname&gt; [&lt;start-point&gt;]
<emphasis>git branch</emphasis> (--set-upstream-to=&lt;upstream&gt; | -u &lt;upstream&gt;) [&lt;branchname&gt;]
<emphasis>git branch</emphasis> --unset-upstream [&lt;branchname&gt;]
<emphasis>git branch</emphasis> (-m | -M) [&lt;oldbranch&gt;] &lt;newbranch&gt;
<emphasis>git branch</emphasis> (-c | -C) [&lt;oldbranch&gt;] &lt;newbranch&gt;
<emphasis>git branch</emphasis> (-d | -D) [-r] &lt;branchname&gt;&#8230;
<emphasis>git branch</emphasis> --edit-description [&lt;branchname&gt;]</literallayout>
</blockquote>
</simplesect>
<simplesect id="git-branch(1)__description">
<title>DESCRIPTION</title>
<simpara>If <emphasis>--list</emphasis> is given, or if there are no non-option arguments, existing
branches are listed; the current branch will be highlighted in green and
marked with an asterisk.  Any branches checked out in linked worktrees will
be highlighted in cyan and marked with a plus sign. Option <emphasis>-r</emphasis> causes the
remote-tracking branches to be listed,
and option <emphasis>-a</emphasis> shows both local and remote branches.</simpara>
<simpara>If a <emphasis>&lt;pattern&gt;</emphasis>
is given, it is used as a shell wildcard to restrict the output to
matching branches. If multiple patterns are given, a branch is shown if
it matches any of the patterns.</simpara>
<simpara>Note that when providing a
<emphasis>&lt;pattern&gt;</emphasis>, you must use <emphasis>--list</emphasis>; otherwise the command may be interpreted
as branch creation.</simpara>
<simpara>With <emphasis>--contains</emphasis>, shows only the branches that contain the named commit
(in other words, the branches whose tip commits are descendants of the
named commit), <emphasis>--no-contains</emphasis> inverts it. With <emphasis>--merged</emphasis>, only branches
merged into the named commit (i.e. the branches whose tip commits are
reachable from the named commit) will be listed.  With <emphasis>--no-merged</emphasis> only
branches not merged into the named commit will be listed.  If the &lt;commit&gt;
argument is missing it defaults to <emphasis>HEAD</emphasis> (i.e. the tip of the current
branch).</simpara>
<simpara>The command's second form creates a new branch head named &lt;branchname&gt;
which points to the current <emphasis>HEAD</emphasis>, or &lt;start-point&gt; if given. As a
special case, for &lt;start-point&gt;, you may use <emphasis>"A...B"</emphasis> as a shortcut for
the merge base of <emphasis>A</emphasis> and <emphasis>B</emphasis> if there is exactly one merge base. You
can leave out at most one of <emphasis>A</emphasis> and <emphasis>B</emphasis>, in which case it defaults to
<emphasis>HEAD</emphasis>.</simpara>
<simpara>Note that this will create the new branch, but it will not switch the
working tree to it; use "git switch &lt;newbranch&gt;" to switch to the
new branch.</simpara>
<simpara>When a local branch is started off a remote-tracking branch, Git sets up the
branch (specifically the <emphasis>branch.&lt;name&gt;.remote</emphasis> and <emphasis>branch.&lt;name&gt;.merge</emphasis>
configuration entries) so that <emphasis>git pull</emphasis> will appropriately merge from
the remote-tracking branch. This behavior may be changed via the global
<emphasis>branch.autoSetupMerge</emphasis> configuration flag. That setting can be
overridden by using the <emphasis>--track</emphasis> and <emphasis>--no-track</emphasis> options, and
changed later using <emphasis>git branch --set-upstream-to</emphasis>.</simpara>
<simpara>With a <emphasis>-m</emphasis> or <emphasis>-M</emphasis> option, &lt;oldbranch&gt; will be renamed to &lt;newbranch&gt;.
If &lt;oldbranch&gt; had a corresponding reflog, it is renamed to match
&lt;newbranch&gt;, and a reflog entry is created to remember the branch
renaming. If &lt;newbranch&gt; exists, -M must be used to force the rename
to happen.</simpara>
<simpara>The <emphasis>-c</emphasis> and <emphasis>-C</emphasis> options have the exact same semantics as <emphasis>-m</emphasis> and
<emphasis>-M</emphasis>, except instead of the branch being renamed, it will be copied to a
new name, along with its config and reflog.</simpara>
<simpara>With a <emphasis>-d</emphasis> or <emphasis>-D</emphasis> option, <emphasis>&lt;branchname&gt;</emphasis> will be deleted.  You may
specify more than one branch for deletion.  If the branch currently
has a reflog then the reflog will also be deleted.</simpara>
<simpara>Use <emphasis>-r</emphasis> together with <emphasis>-d</emphasis> to delete remote-tracking branches. Note, that it
only makes sense to delete remote-tracking branches if they no longer exist
in the remote repository or if <emphasis>git fetch</emphasis> was configured not to fetch
them again. See also the <emphasis>prune</emphasis> subcommand of <xref linkend="git-remote(1)" /> for a
way to clean up all obsolete remote-tracking branches.</simpara>
</simplesect>
<simplesect id="git-branch(1)__options">
<title>OPTIONS</title>
<variablelist>
<varlistentry>
<term>
-d
</term>
<term>
--delete
</term>
<listitem>
<simpara>
        Delete a branch. The branch must be fully merged in its
        upstream branch, or in <emphasis>HEAD</emphasis> if no upstream was set with
        <emphasis>--track</emphasis> or <emphasis>--set-upstream-to</emphasis>.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-D
</term>
<listitem>
<simpara>
        Shortcut for <emphasis>--delete --force</emphasis>.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--create-reflog
</term>
<listitem>
<simpara>
        Create the branch's reflog.  This activates recording of
        all changes made to the branch ref, enabling use of date
        based sha1 expressions such as "&lt;branchname&gt;@{yesterday}".
        Note that in non-bare repositories, reflogs are usually
        enabled by default by the <emphasis>core.logAllRefUpdates</emphasis> config option.
        The negated form <emphasis>--no-create-reflog</emphasis> only overrides an earlier
        <emphasis>--create-reflog</emphasis>, but currently does not negate the setting of
        <emphasis>core.logAllRefUpdates</emphasis>.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-f
</term>
<term>
--force
</term>
<listitem>
<simpara>
        Reset &lt;branchname&gt; to &lt;start-point&gt;, even if &lt;branchname&gt; exists
        already. Without <emphasis>-f</emphasis>, <emphasis>git branch</emphasis> refuses to change an existing branch.
        In combination with <emphasis>-d</emphasis> (or <emphasis>--delete</emphasis>), allow deleting the
        branch irrespective of its merged status, or whether it even
        points to a valid commit. In combination with
        <emphasis>-m</emphasis> (or <emphasis>--move</emphasis>), allow renaming the branch even if the new
        branch name already exists, the same applies for <emphasis>-c</emphasis> (or <emphasis>--copy</emphasis>).
</simpara>
<simpara>Note that <emphasis>git branch -f &lt;branchname&gt; [&lt;start-point&gt;]</emphasis>, even with <emphasis>-f</emphasis>,
refuses to change an existing branch <emphasis>&lt;branchname&gt;</emphasis> that is checked out
in another worktree linked to the same repository.</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-m
</term>
<term>
--move
</term>
<listitem>
<simpara>
        Move/rename a branch, together with its config and reflog.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-M
</term>
<listitem>
<simpara>
        Shortcut for <emphasis>--move --force</emphasis>.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-c
</term>
<term>
--copy
</term>
<listitem>
<simpara>
        Copy a branch, together with its config and reflog.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-C
</term>
<listitem>
<simpara>
        Shortcut for <emphasis>--copy --force</emphasis>.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--color[=&lt;when&gt;]
</term>
<listitem>
<simpara>
        Color branches to highlight current, local, and
        remote-tracking branches.
        The value must be always (the default), never, or auto.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--no-color
</term>
<listitem>
<simpara>
        Turn off branch colors, even when the configuration file gives the
        default to color output.
        Same as <emphasis>--color=never</emphasis>.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-i
</term>
<term>
--ignore-case
</term>
<listitem>
<simpara>
        Sorting and filtering branches are case insensitive.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--omit-empty
</term>
<listitem>
<simpara>
        Do not print a newline after formatted refs where the format expands
        to the empty string.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--column[=&lt;options&gt;]
</term>
<term>
--no-column
</term>
<listitem>
<simpara>
        Display branch listing in columns. See configuration variable
        <emphasis>column.branch</emphasis> for option syntax. <emphasis>--column</emphasis> and <emphasis>--no-column</emphasis>
        without options are equivalent to <emphasis>always</emphasis> and <emphasis>never</emphasis> respectively.
</simpara>
<simpara>This option is only applicable in non-verbose mode.</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-r
</term>
<term>
--remotes
</term>
<listitem>
<simpara>
        List or delete (if used with -d) the remote-tracking branches.
        Combine with <emphasis>--list</emphasis> to match the optional pattern(s).
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-a
</term>
<term>
--all
</term>
<listitem>
<simpara>
        List both remote-tracking branches and local branches.
        Combine with <emphasis>--list</emphasis> to match optional pattern(s).
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-l
</term>
<term>
--list
</term>
<listitem>
<simpara>
        List branches.  With optional <emphasis>&lt;pattern&gt;...</emphasis>, e.g. <emphasis>git
        branch --list 'maint-*'</emphasis>, list only the branches that match
        the pattern(s).
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--show-current
</term>
<listitem>
<simpara>
        Print the name of the current branch. In detached HEAD state,
        nothing is printed.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-v
</term>
<term>
-vv
</term>
<term>
--verbose
</term>
<listitem>
<simpara>
        When in list mode,
        show sha1 and commit subject line for each head, along with
        relationship to upstream branch (if any). If given twice, print
        the path of the linked worktree (if any) and the name of the upstream
        branch, as well (see also <emphasis>git remote show &lt;remote&gt;</emphasis>).  Note that the
        current worktree's HEAD will not have its path printed (it will always
        be your current directory).
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-q
</term>
<term>
--quiet
</term>
<listitem>
<simpara>
        Be more quiet when creating or deleting a branch, suppressing
        non-error messages.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--abbrev=&lt;n&gt;
</term>
<listitem>
<simpara>
        In the verbose listing that show the commit object name,
        show the shortest prefix that is at least <emphasis>&lt;n&gt;</emphasis> hexdigits
        long that uniquely refers the object.
        The default value is 7 and can be overridden by the <emphasis>core.abbrev</emphasis>
        config option.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--no-abbrev
</term>
<listitem>
<simpara>
        Display the full sha1s in the output listing rather than abbreviating them.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-t
</term>
<term>
--track[=(direct|inherit)]
</term>
<listitem>
<simpara>
        When creating a new branch, set up <emphasis>branch.&lt;name&gt;.remote</emphasis> and
        <emphasis>branch.&lt;name&gt;.merge</emphasis> configuration entries to set "upstream" tracking
        configuration for the new branch. This
        configuration will tell git to show the relationship between the
        two branches in <emphasis>git status</emphasis> and <emphasis>git branch -v</emphasis>. Furthermore,
        it directs <emphasis>git pull</emphasis> without arguments to pull from the
        upstream when the new branch is checked out.
</simpara>
<simpara>The exact upstream branch is chosen depending on the optional argument:
<emphasis>-t</emphasis>, <emphasis>--track</emphasis>, or <emphasis>--track=direct</emphasis> means to use the start-point branch
itself as the upstream; <emphasis>--track=inherit</emphasis> means to copy the upstream
configuration of the start-point branch.</simpara>
<simpara>The branch.autoSetupMerge configuration variable specifies how <emphasis>git switch</emphasis>,
<emphasis>git checkout</emphasis> and <emphasis>git branch</emphasis> should behave when neither <emphasis>--track</emphasis> nor
<emphasis>--no-track</emphasis> are specified:</simpara>
<simpara>The default option, <emphasis>true</emphasis>, behaves as though <emphasis>--track=direct</emphasis>
were given whenever the start-point is a remote-tracking branch.
<emphasis>false</emphasis> behaves as if <emphasis>--no-track</emphasis> were given. <emphasis>always</emphasis> behaves as though
<emphasis>--track=direct</emphasis> were given. <emphasis>inherit</emphasis> behaves as though <emphasis>--track=inherit</emphasis>
were given. <emphasis>simple</emphasis> behaves as though <emphasis>--track=direct</emphasis> were given only when
the start-point is a remote-tracking branch and the new branch has the same
name as the remote branch.</simpara>
<simpara>See <xref linkend="git-pull(1)" /> and <xref linkend="git-config(1)" /> for additional discussion on
how the <emphasis>branch.&lt;name&gt;.remote</emphasis> and <emphasis>branch.&lt;name&gt;.merge</emphasis> options are used.</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--no-track
</term>
<listitem>
<simpara>
        Do not set up "upstream" configuration, even if the
        branch.autoSetupMerge configuration variable is set.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--recurse-submodules
</term>
<listitem>
<simpara>
        THIS OPTION IS EXPERIMENTAL! Causes the current command to
        recurse into submodules if <emphasis>submodule.propagateBranches</emphasis> is
        enabled. See <emphasis>submodule.propagateBranches</emphasis> in
        <xref linkend="git-config(1)" />. Currently, only branch creation is
        supported.
</simpara>
<simpara>When used in branch creation, a new branch &lt;branchname&gt; will be created
in the superproject and all of the submodules in the superproject's
&lt;start-point&gt;. In submodules, the branch will point to the submodule
commit in the superproject's &lt;start-point&gt; but the branch's tracking
information will be set up based on the submodule's branches and remotes
e.g. <emphasis>git branch --recurse-submodules topic origin/main</emphasis> will create the
submodule branch "topic" that points to the submodule commit in the
superproject's "origin/main", but tracks the submodule's "origin/main".</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--set-upstream
</term>
<listitem>
<simpara>
        As this option had confusing syntax, it is no longer supported.
        Please use <emphasis>--track</emphasis> or <emphasis>--set-upstream-to</emphasis> instead.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-u &lt;upstream&gt;
</term>
<term>
--set-upstream-to=&lt;upstream&gt;
</term>
<listitem>
<simpara>
        Set up &lt;branchname&gt;'s tracking information so &lt;upstream&gt; is
        considered &lt;branchname&gt;'s upstream branch. If no &lt;branchname&gt;
        is specified, then it defaults to the current branch.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--unset-upstream
</term>
<listitem>
<simpara>
        Remove the upstream information for &lt;branchname&gt;. If no branch
        is specified it defaults to the current branch.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--edit-description
</term>
<listitem>
<simpara>
        Open an editor and edit the text to explain what the branch is
        for, to be used by various other commands (e.g. <emphasis>format-patch</emphasis>,
        <emphasis>request-pull</emphasis>, and <emphasis>merge</emphasis> (if enabled)). Multi-line explanations
        may be used.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--contains [&lt;commit&gt;]
</term>
<listitem>
<simpara>
        Only list branches which contain the specified commit (HEAD
        if not specified). Implies <emphasis>--list</emphasis>.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--no-contains [&lt;commit&gt;]
</term>
<listitem>
<simpara>
        Only list branches which don't contain the specified commit
        (HEAD if not specified). Implies <emphasis>--list</emphasis>.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--merged [&lt;commit&gt;]
</term>
<listitem>
<simpara>
        Only list branches whose tips are reachable from the
        specified commit (HEAD if not specified). Implies <emphasis>--list</emphasis>.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--no-merged [&lt;commit&gt;]
</term>
<listitem>
<simpara>
        Only list branches whose tips are not reachable from the
        specified commit (HEAD if not specified). Implies <emphasis>--list</emphasis>.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
&lt;branchname&gt;
</term>
<listitem>
<simpara>
        The name of the branch to create or delete.
        The new branch name must pass all checks defined by
        <xref linkend="git-check-ref-format(1)" />.  Some of these checks
        may restrict the characters allowed in a branch name.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
&lt;start-point&gt;
</term>
<listitem>
<simpara>
        The new branch head will point to this commit.  It may be
        given as a branch name, a commit-id, or a tag.  If this
        option is omitted, the current HEAD will be used instead.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
&lt;oldbranch&gt;
</term>
<listitem>
<simpara>
        The name of an existing branch.  If this option is omitted,
        the name of the current branch will be used instead.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
&lt;newbranch&gt;
</term>
<listitem>
<simpara>
        The new name for an existing branch. The same restrictions as for
        &lt;branchname&gt; apply.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--sort=&lt;key&gt;
</term>
<listitem>
<simpara>
        Sort based on the key given. Prefix <emphasis>-</emphasis> to sort in descending
        order of the value. You may use the --sort=&lt;key&gt; option
        multiple times, in which case the last key becomes the primary
        key. The keys supported are the same as those in <emphasis>git
        for-each-ref</emphasis>. Sort order defaults to the value configured for the
        <emphasis>branch.sort</emphasis> variable if it exists, or to sorting based on the
        full refname (including <emphasis>refs/...</emphasis> prefix). This lists
        detached HEAD (if present) first, then local branches and
        finally remote-tracking branches. See <xref linkend="git-config(1)" />.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--points-at &lt;object&gt;
</term>
<listitem>
<simpara>
        Only list branches of the given object.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--format &lt;format&gt;
</term>
<listitem>
<simpara>
        A string that interpolates <emphasis>%(fieldname)</emphasis> from a branch ref being shown
        and the object it points at.  The format is the same as
        that of <xref linkend="git-for-each-ref(1)" />.
</simpara>
</listitem>
</varlistentry>
</variablelist>
</simplesect>
<simplesect id="git-branch(1)__configuration">
<title>CONFIGURATION</title>
<simpara><emphasis>pager.branch</emphasis> is only respected when listing branches, i.e., when
<emphasis>--list</emphasis> is used or implied. The default is to use a pager.
See <xref linkend="git-config(1)" />.</simpara>
<simpara>Everything above this line in this section isn't included from the
<xref linkend="git-config(1)" /> documentation. The content that follows is the
same as what's found there:</simpara>
<variablelist>
<varlistentry>
<term>
branch.autoSetupMerge
</term>
<listitem>
<simpara>
        Tells <emphasis>git branch</emphasis>, <emphasis>git switch</emphasis> and <emphasis>git checkout</emphasis> to set up new branches
        so that <xref linkend="git-pull(1)" /> will appropriately merge from the
        starting point branch. Note that even if this option is not set,
        this behavior can be chosen per-branch using the <emphasis>--track</emphasis>
        and <emphasis>--no-track</emphasis> options. The valid settings are: <emphasis>false</emphasis> -- no
        automatic setup is done; <emphasis>true</emphasis> -- automatic setup is done when the
        starting point is a remote-tracking branch; <emphasis>always</emphasis> --
        automatic setup is done when the starting point is either a
        local branch or remote-tracking branch; <emphasis>inherit</emphasis> -- if the starting point
        has a tracking configuration, it is copied to the new
        branch; <emphasis>simple</emphasis> -- automatic setup is done only when the starting point
        is a remote-tracking branch and the new branch has the same name as the
        remote branch. This option defaults to true.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
branch.autoSetupRebase
</term>
<listitem>
<simpara>
        When a new branch is created with <emphasis>git branch</emphasis>, <emphasis>git switch</emphasis> or <emphasis>git checkout</emphasis>
        that tracks another branch, this variable tells Git to set
        up pull to rebase instead of merge (see "branch.&lt;name&gt;.rebase").
        When <emphasis>never</emphasis>, rebase is never automatically set to true.
        When <emphasis>local</emphasis>, rebase is set to true for tracked branches of
        other local branches.
        When <emphasis>remote</emphasis>, rebase is set to true for tracked branches of
        remote-tracking branches.
        When <emphasis>always</emphasis>, rebase will be set to true for all tracking
        branches.
        See "branch.autoSetupMerge" for details on how to set up a
        branch to track another branch.
        This option defaults to never.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
branch.sort
</term>
<listitem>
<simpara>
        This variable controls the sort ordering of branches when displayed by
        <xref linkend="git-branch(1)" />. Without the "--sort=&lt;value&gt;" option provided, the
        value of this variable will be used as the default.
        See <xref linkend="git-for-each-ref(1)" /> field names for valid values.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
branch.&lt;name&gt;.remote
</term>
<listitem>
<simpara>
        When on branch &lt;name&gt;, it tells <emphasis>git fetch</emphasis> and <emphasis>git push</emphasis>
        which remote to fetch from or push to.  The remote to push to
        may be overridden with <emphasis>remote.pushDefault</emphasis> (for all branches).
        The remote to push to, for the current branch, may be further
        overridden by <emphasis>branch.&lt;name&gt;.pushRemote</emphasis>.  If no remote is
        configured, or if you are not on any branch and there is more than
        one remote defined in the repository, it defaults to <emphasis>origin</emphasis> for
        fetching and <emphasis>remote.pushDefault</emphasis> for pushing.
        Additionally, <emphasis>.</emphasis> (a period) is the current local repository
        (a dot-repository), see <emphasis>branch.&lt;name&gt;.merge</emphasis>'s final note below.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
branch.&lt;name&gt;.pushRemote
</term>
<listitem>
<simpara>
        When on branch &lt;name&gt;, it overrides <emphasis>branch.&lt;name&gt;.remote</emphasis> for
        pushing.  It also overrides <emphasis>remote.pushDefault</emphasis> for pushing
        from branch &lt;name&gt;.  When you pull from one place (e.g. your
        upstream) and push to another place (e.g. your own publishing
        repository), you would want to set <emphasis>remote.pushDefault</emphasis> to
        specify the remote to push to for all branches, and use this
        option to override it for a specific branch.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
branch.&lt;name&gt;.merge
</term>
<listitem>
<simpara>
        Defines, together with branch.&lt;name&gt;.remote, the upstream branch
        for the given branch. It tells <emphasis>git fetch</emphasis>/<emphasis>git pull</emphasis>/<emphasis>git rebase</emphasis> which
        branch to merge and can also affect <emphasis>git push</emphasis> (see push.default).
        When in branch &lt;name&gt;, it tells <emphasis>git fetch</emphasis> the default
        refspec to be marked for merging in FETCH_HEAD. The value is
        handled like the remote part of a refspec, and must match a
        ref which is fetched from the remote given by
        "branch.&lt;name&gt;.remote".
        The merge information is used by <emphasis>git pull</emphasis> (which first calls
        <emphasis>git fetch</emphasis>) to lookup the default branch for merging. Without
        this option, <emphasis>git pull</emphasis> defaults to merge the first refspec fetched.
        Specify multiple values to get an octopus merge.
        If you wish to setup <emphasis>git pull</emphasis> so that it merges into &lt;name&gt; from
        another branch in the local repository, you can point
        branch.&lt;name&gt;.merge to the desired branch, and use the relative path
        setting <emphasis>.</emphasis> (a period) for branch.&lt;name&gt;.remote.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
branch.&lt;name&gt;.mergeOptions
</term>
<listitem>
<simpara>
        Sets default options for merging into branch &lt;name&gt;. The syntax and
        supported options are the same as those of <xref linkend="git-merge(1)" />, but
        option values containing whitespace characters are currently not
        supported.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
branch.&lt;name&gt;.rebase
</term>
<listitem>
<simpara>
        When true, rebase the branch &lt;name&gt; on top of the fetched branch,
        instead of merging the default branch from the default remote when
        "git pull" is run. See "pull.rebase" for doing this in a non
        branch-specific manner.
</simpara>
<simpara>When <emphasis>merges</emphasis> (or just <emphasis>m</emphasis>), pass the <emphasis>--rebase-merges</emphasis> option to <emphasis>git rebase</emphasis>
so that the local merge commits are included in the rebase (see
<xref linkend="git-rebase(1)" /> for details).</simpara>
<simpara>When the value is <emphasis>interactive</emphasis> (or just <emphasis>i</emphasis>), the rebase is run in interactive
mode.</simpara>
<simpara><emphasis role="strong">NOTE</emphasis>: this is a possibly dangerous operation; do <emphasis role="strong">not</emphasis> use
it unless you understand the implications (see <xref linkend="git-rebase(1)" />
for details).</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
branch.&lt;name&gt;.description
</term>
<listitem>
<simpara>
        Branch description, can be edited with
        <emphasis>git branch --edit-description</emphasis>. Branch description is
        automatically added to the format-patch cover letter or
        request-pull summary.
</simpara>
</listitem>
</varlistentry>
</variablelist>
</simplesect>
<simplesect id="git-branch(1)__examples">
<title>EXAMPLES</title>
<variablelist>
<varlistentry>
<term>
Start development from a known tag
</term>
<listitem>
<screen>$ git clone git://git.kernel.org/pub/scm/.../linux-2.6 my2.6
$ cd my2.6
$ git branch my2.6.14 v2.6.14   <co id="git-branch_CO1-1"/>
$ git switch my2.6.14</screen>
<calloutlist>
<callout arearefs="git-branch_CO1-1">
<para>
This step and the next one could be combined into a single step with
    "checkout -b my2.6.14 v2.6.14".
</para>
</callout>
</calloutlist>
</listitem>
</varlistentry>
<varlistentry>
<term>
Delete an unneeded branch
</term>
<listitem>
<screen>$ git clone git://git.kernel.org/.../git.git my.git
$ cd my.git
$ git branch -d -r origin/todo origin/html origin/man   <co id="git-branch_CO2-1"/>
$ git branch -D test                                    <co id="git-branch_CO2-2"/></screen>
<calloutlist>
<callout arearefs="git-branch_CO2-1">
<para>
Delete the remote-tracking branches "todo", "html" and "man". The next
    <emphasis>fetch</emphasis> or <emphasis>pull</emphasis> will create them again unless you configure them not to.
    See <xref linkend="git-fetch(1)" />.
</para>
</callout>
<callout arearefs="git-branch_CO2-2">
<para>
Delete the "test" branch even if the "master" branch (or whichever branch
    is currently checked out) does not have all commits from the test branch.
</para>
</callout>
</calloutlist>
</listitem>
</varlistentry>
<varlistentry>
<term>
Listing branches from a specific remote
</term>
<listitem>
<screen>$ git branch -r -l '&lt;remote&gt;/&lt;pattern&gt;'                 <co id="git-branch_CO3-1"/>
$ git for-each-ref 'refs/remotes/&lt;remote&gt;/&lt;pattern&gt;'    <co id="git-branch_CO3-2"/></screen>
<calloutlist>
<callout arearefs="git-branch_CO3-1">
<para>
Using <emphasis>-a</emphasis> would conflate &lt;remote&gt; with any local branches you happen to
    have been prefixed with the same &lt;remote&gt; pattern.
</para>
</callout>
<callout arearefs="git-branch_CO3-2">
<para>
<emphasis>for-each-ref</emphasis> can take a wide range of options. See <xref linkend="git-for-each-ref(1)" />
</para>
</callout>
</calloutlist>
</listitem>
</varlistentry>
</variablelist>
<simpara>Patterns will normally need quoting.</simpara>
</simplesect>
<simplesect id="git-branch(1)__notes">
<title>NOTES</title>
<simpara>If you are creating a branch that you want to switch to immediately,
it is easier to use the "git switch" command with its <emphasis>-c</emphasis> option to
do the same thing with a single command.</simpara>
<simpara>The options <emphasis>--contains</emphasis>, <emphasis>--no-contains</emphasis>, <emphasis>--merged</emphasis> and <emphasis>--no-merged</emphasis>
serve four related but different purposes:</simpara>
<itemizedlist>
<listitem>
<simpara>
<emphasis>--contains &lt;commit&gt;</emphasis> is used to find all branches which will need
  special attention if &lt;commit&gt; were to be rebased or amended, since those
  branches contain the specified &lt;commit&gt;.
</simpara>
</listitem>
<listitem>
<simpara>
<emphasis>--no-contains &lt;commit&gt;</emphasis> is the inverse of that, i.e. branches that don't
  contain the specified &lt;commit&gt;.
</simpara>
</listitem>
<listitem>
<simpara>
<emphasis>--merged</emphasis> is used to find all branches which can be safely deleted,
  since those branches are fully contained by HEAD.
</simpara>
</listitem>
<listitem>
<simpara>
<emphasis>--no-merged</emphasis> is used to find branches which are candidates for merging
  into HEAD, since those branches are not fully contained by HEAD.
</simpara>
</listitem>
</itemizedlist>
<simpara>When combining multiple <emphasis>--contains</emphasis> and <emphasis>--no-contains</emphasis> filters, only
references that contain at least one of the <emphasis>--contains</emphasis> commits and
contain none of the <emphasis>--no-contains</emphasis> commits are shown.</simpara>
<simpara>When combining multiple <emphasis>--merged</emphasis> and <emphasis>--no-merged</emphasis> filters, only
references that are reachable from at least one of the <emphasis>--merged</emphasis>
commits and from none of the <emphasis>--no-merged</emphasis> commits are shown.</simpara>
</simplesect>
<simplesect id="git-branch(1)__see_also">
<title>SEE ALSO</title>
<simpara><xref linkend="git-check-ref-format(1)" />,
<xref linkend="git-fetch(1)" />,
<xref linkend="git-remote(1)" />,
<ulink url="https://www.kernel.org/pub/software/scm/git/docs/user-manual.html#what-is-a-branch"><citetitle>Understanding history: What is
a branch?</citetitle></ulink> in the Git User's Manual.</simpara>
</simplesect>
<simplesect id="git-branch(1)__git">
<title>GIT</title>
<simpara>Part of the <xref linkend="git(1)" /> suite</simpara>
</simplesect>
</sect2>
