{
    "mode": "man",
    "parameter": "git-branch",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/git-branch/1/json",
    "generated": "2026-09-02T11:15:02Z",
    "synopsis": "git branch [--color[=<when>] | --no-color] [--show-current]\n[-v [--abbrev=<n> | --no-abbrev]]\n[--column[=<options>] | --no-column] [--sort=<key>]\n[--merged [<commit>]] [--no-merged [<commit>]]\n[--contains [<commit>]] [--no-contains [<commit>]]\n[--points-at <object>] [--format=<format>]\n[(-r | --remotes) | (-a | --all)]\n[--list] [<pattern>...]\ngit branch [--track[=(direct|inherit)] | --no-track] [-f]\n[--recurse-submodules] <branchname> [<start-point>]\ngit branch (--set-upstream-to=<upstream> | -u <upstream>) [<branchname>]\ngit branch --unset-upstream [<branchname>]\ngit branch (-m | -M) [<oldbranch>] <newbranch>\ngit branch (-c | -C) [<oldbranch>] <newbranch>\ngit branch (-d | -D) [-r] <branchname>...\ngit branch --edit-description [<branchname>]",
    "sections": {
        "NAME": {
            "content": "git-branch - List, create, or delete branches\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "git branch [--color[=<when>] | --no-color] [--show-current]\n[-v [--abbrev=<n> | --no-abbrev]]\n[--column[=<options>] | --no-column] [--sort=<key>]\n[--merged [<commit>]] [--no-merged [<commit>]]\n[--contains [<commit>]] [--no-contains [<commit>]]\n[--points-at <object>] [--format=<format>]\n[(-r | --remotes) | (-a | --all)]\n[--list] [<pattern>...]\ngit branch [--track[=(direct|inherit)] | --no-track] [-f]\n[--recurse-submodules] <branchname> [<start-point>]\ngit branch (--set-upstream-to=<upstream> | -u <upstream>) [<branchname>]\ngit branch --unset-upstream [<branchname>]\ngit branch (-m | -M) [<oldbranch>] <newbranch>\ngit branch (-c | -C) [<oldbranch>] <newbranch>\ngit branch (-d | -D) [-r] <branchname>...\ngit branch --edit-description [<branchname>]\n\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "If --list is given, or if there are no non-option arguments, existing branches are listed;\nthe current branch will be highlighted in green and marked with an asterisk. Any branches\nchecked out in linked worktrees will be highlighted in cyan and marked with a plus sign.\nOption -r causes the remote-tracking branches to be listed, and option -a shows both local\nand remote branches.\n\nIf a <pattern> is given, it is used as a shell wildcard to restrict the output to matching\nbranches. If multiple patterns are given, a branch is shown if it matches any of the\npatterns.\n\nNote that when providing a <pattern>, you must use --list; otherwise the command may be\ninterpreted as branch creation.\n\nWith --contains, shows only the branches that contain the named commit (in other words, the\nbranches whose tip commits are descendants of the named commit), --no-contains inverts it.\nWith --merged, only branches merged into the named commit (i.e. the branches whose tip\ncommits are reachable from the named commit) will be listed. With --no-merged only branches\nnot merged into the named commit will be listed. If the <commit> argument is missing it\ndefaults to HEAD (i.e. the tip of the current branch).\n\nThe command’s second form creates a new branch head named <branchname> which points to the\ncurrent HEAD, or <start-point> if given. As a special case, for <start-point>, you may use\n\"A...B\" as a shortcut for the merge base of A and B if there is exactly one merge base. You\ncan leave out at most one of A and B, in which case it defaults to HEAD.\n\nNote that this will create the new branch, but it will not switch the working tree to it; use\n\"git switch <newbranch>\" to switch to the new branch.\n\nWhen a local branch is started off a remote-tracking branch, Git sets up the branch\n(specifically the branch.<name>.remote and branch.<name>.merge configuration entries) so that\ngit pull will appropriately merge from the remote-tracking branch. This behavior may be\nchanged via the global branch.autoSetupMerge configuration flag. That setting can be\noverridden by using the --track and --no-track options, and changed later using git branch\n--set-upstream-to.\n\nWith a -m or -M option, <oldbranch> will be renamed to <newbranch>. If <oldbranch> had a\ncorresponding reflog, it is renamed to match <newbranch>, and a reflog entry is created to\nremember the branch renaming. If <newbranch> exists, -M must be used to force the rename to\nhappen.\n\nThe -c and -C options have the exact same semantics as -m and -M, except instead of the\nbranch being renamed, it will be copied to a new name, along with its config and reflog.\n\nWith a -d or -D option, <branchname> will be deleted. You may specify more than one branch\nfor deletion. If the branch currently has a reflog then the reflog will also be deleted.\n\nUse -r together with -d to delete remote-tracking branches. Note, that it only makes sense to\ndelete remote-tracking branches if they no longer exist in the remote repository or if git\nfetch was configured not to fetch them again. See also the prune subcommand of git-remote(1)\nfor a way to clean up all obsolete remote-tracking branches.\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "",
            "subsections": [
                {
                    "name": "-d, --delete",
                    "content": "Delete a branch. The branch must be fully merged in its upstream branch, or in HEAD if no\nupstream was set with --track or --set-upstream-to.\n",
                    "flag": "-d",
                    "long": "--delete"
                },
                {
                    "name": "-D",
                    "content": "Shortcut for --delete --force.\n",
                    "flag": "-D"
                },
                {
                    "name": "--create-reflog",
                    "content": "Create the branch’s reflog. This activates recording of all changes made to the branch\nref, enabling use of date based sha1 expressions such as \"<branchname>@{yesterday}\". Note\nthat in non-bare repositories, reflogs are usually enabled by default by the\ncore.logAllRefUpdates config option. The negated form --no-create-reflog only overrides\nan earlier --create-reflog, but currently does not negate the setting of\ncore.logAllRefUpdates.\n",
                    "long": "--create-reflog"
                },
                {
                    "name": "-f, --force",
                    "content": "Reset <branchname> to <start-point>, even if <branchname> exists already. Without -f, git\nbranch refuses to change an existing branch. In combination with -d (or --delete), allow\ndeleting the branch irrespective of its merged status, or whether it even points to a\nvalid commit. In combination with -m (or --move), allow renaming the branch even if the\nnew branch name already exists, the same applies for -c (or --copy).\n\nNote that git branch -f <branchname> [<start-point>], even with -f, refuses to change an\nexisting branch <branchname> that is checked out in another worktree linked to the same\nrepository.\n",
                    "flag": "-f",
                    "long": "--force"
                },
                {
                    "name": "-m, --move",
                    "content": "Move/rename a branch, together with its config and reflog.\n",
                    "flag": "-m",
                    "long": "--move"
                },
                {
                    "name": "-M",
                    "content": "Shortcut for --move --force.\n",
                    "flag": "-M"
                },
                {
                    "name": "-c, --copy",
                    "content": "Copy a branch, together with its config and reflog.\n",
                    "flag": "-c",
                    "long": "--copy"
                },
                {
                    "name": "-C",
                    "content": "Shortcut for --copy --force.\n\n--color[=<when>]\nColor branches to highlight current, local, and remote-tracking branches. The value must\nbe always (the default), never, or auto.\n",
                    "flag": "-C"
                },
                {
                    "name": "--no-color",
                    "content": "Turn off branch colors, even when the configuration file gives the default to color\noutput. Same as --color=never.\n",
                    "long": "--no-color"
                },
                {
                    "name": "-i, --ignore-case",
                    "content": "Sorting and filtering branches are case insensitive.\n",
                    "flag": "-i",
                    "long": "--ignore-case"
                },
                {
                    "name": "--omit-empty",
                    "content": "Do not print a newline after formatted refs where the format expands to the empty string.\n\n--column[=<options>], --no-column\nDisplay branch listing in columns. See configuration variable column.branch for option\nsyntax.  --column and --no-column without options are equivalent to always and never\nrespectively.\n\nThis option is only applicable in non-verbose mode.\n",
                    "long": "--omit-empty"
                },
                {
                    "name": "-r, --remotes",
                    "content": "List or delete (if used with -d) the remote-tracking branches. Combine with --list to\nmatch the optional pattern(s).\n",
                    "flag": "-r",
                    "long": "--remotes"
                },
                {
                    "name": "-a, --all",
                    "content": "List both remote-tracking branches and local branches. Combine with --list to match\noptional pattern(s).\n",
                    "flag": "-a",
                    "long": "--all"
                },
                {
                    "name": "-l, --list",
                    "content": "List branches. With optional <pattern>..., e.g.  git branch --list 'maint-*', list only\nthe branches that match the pattern(s).\n",
                    "flag": "-l",
                    "long": "--list"
                },
                {
                    "name": "--show-current",
                    "content": "Print the name of the current branch. In detached HEAD state, nothing is printed.\n",
                    "long": "--show-current"
                },
                {
                    "name": "-v, -vv, --verbose",
                    "content": "When in list mode, show sha1 and commit subject line for each head, along with\nrelationship to upstream branch (if any). If given twice, print the path of the linked\nworktree (if any) and the name of the upstream branch, as well (see also git remote show\n<remote>). Note that the current worktree’s HEAD will not have its path printed (it will\nalways be your current directory).\n",
                    "flag": "-v",
                    "long": "--verbose"
                },
                {
                    "name": "-q, --quiet",
                    "content": "Be more quiet when creating or deleting a branch, suppressing non-error messages.\n\n--abbrev=<n>\nIn the verbose listing that show the commit object name, show the shortest prefix that is\nat least <n> hexdigits long that uniquely refers the object. The default value is 7 and\ncan be overridden by the core.abbrev config option.\n",
                    "flag": "-q",
                    "long": "--quiet"
                },
                {
                    "name": "--no-abbrev",
                    "content": "Display the full sha1s in the output listing rather than abbreviating them.\n",
                    "long": "--no-abbrev"
                },
                {
                    "name": "-t, --track[=(direct|inherit)]",
                    "content": "When creating a new branch, set up branch.<name>.remote and branch.<name>.merge\nconfiguration entries to set \"upstream\" tracking configuration for the new branch. This\nconfiguration will tell git to show the relationship between the two branches in git\nstatus and git branch -v. Furthermore, it directs git pull without arguments to pull from\nthe upstream when the new branch is checked out.\n\nThe exact upstream branch is chosen depending on the optional argument: -t, --track, or\n--track=direct means to use the start-point branch itself as the upstream;\n--track=inherit means to copy the upstream configuration of the start-point branch.\n\nThe branch.autoSetupMerge configuration variable specifies how git switch, git checkout\nand git branch should behave when neither --track nor --no-track are specified:\n\nThe default option, true, behaves as though --track=direct were given whenever the\nstart-point is a remote-tracking branch.  false behaves as if --no-track were given.\nalways behaves as though --track=direct were given.  inherit behaves as though\n--track=inherit were given.  simple behaves as though --track=direct were given only when\nthe start-point is a remote-tracking branch and the new branch has the same name as the\nremote branch.\n\nSee git-pull(1) and git-config(1) for additional discussion on how the\nbranch.<name>.remote and branch.<name>.merge options are used.\n",
                    "flag": "-t"
                },
                {
                    "name": "--no-track",
                    "content": "Do not set up \"upstream\" configuration, even if the branch.autoSetupMerge configuration\nvariable is set.\n",
                    "long": "--no-track"
                },
                {
                    "name": "--recurse-submodules",
                    "content": "THIS OPTION IS EXPERIMENTAL! Causes the current command to recurse into submodules if\nsubmodule.propagateBranches is enabled. See submodule.propagateBranches in git-config(1).\nCurrently, only branch creation is supported.\n\nWhen used in branch creation, a new branch <branchname> will be created in the\nsuperproject and all of the submodules in the superproject’s <start-point>. In\nsubmodules, the branch will point to the submodule commit in the superproject’s\n<start-point> but the branch’s tracking information will be set up based on the\nsubmodule’s branches and remotes e.g.  git branch --recurse-submodules topic origin/main\nwill create the submodule branch \"topic\" that points to the submodule commit in the\nsuperproject’s \"origin/main\", but tracks the submodule’s \"origin/main\".\n",
                    "long": "--recurse-submodules"
                },
                {
                    "name": "--set-upstream",
                    "content": "As this option had confusing syntax, it is no longer supported. Please use --track or\n--set-upstream-to instead.\n\n-u <upstream>, --set-upstream-to=<upstream>\nSet up <branchname>'s tracking information so <upstream> is considered <branchname>'s\nupstream branch. If no <branchname> is specified, then it defaults to the current branch.\n",
                    "long": "--set-upstream"
                },
                {
                    "name": "--unset-upstream",
                    "content": "Remove the upstream information for <branchname>. If no branch is specified it defaults\nto the current branch.\n",
                    "long": "--unset-upstream"
                },
                {
                    "name": "--edit-description",
                    "content": "Open an editor and edit the text to explain what the branch is for, to be used by various\nother commands (e.g.  format-patch, request-pull, and merge (if enabled)). Multi-line\nexplanations may be used.\n\n--contains [<commit>]\nOnly list branches which contain the specified commit (HEAD if not specified). Implies\n--list.\n\n--no-contains [<commit>]\nOnly list branches which don’t contain the specified commit (HEAD if not specified).\nImplies --list.\n\n--merged [<commit>]\nOnly list branches whose tips are reachable from the specified commit (HEAD if not\nspecified). Implies --list.\n\n--no-merged [<commit>]\nOnly list branches whose tips are not reachable from the specified commit (HEAD if not\nspecified). Implies --list.\n\n<branchname>\nThe name of the branch to create or delete. The new branch name must pass all checks\ndefined by git-check-ref-format(1). Some of these checks may restrict the characters\nallowed in a branch name.\n\n<start-point>\nThe new branch head will point to this commit. It may be given as a branch name, a\ncommit-id, or a tag. If this option is omitted, the current HEAD will be used instead.\n\n<oldbranch>\nThe name of an existing branch to rename.\n\n<newbranch>\nThe new name for an existing branch. The same restrictions as for <branchname> apply.\n\n--sort=<key>\nSort based on the key given. Prefix - to sort in descending order of the value. You may\nuse the --sort=<key> option multiple times, in which case the last key becomes the\nprimary key. The keys supported are the same as those in git for-each-ref. Sort order\ndefaults to the value configured for the branch.sort variable if it exists, or to sorting\nbased on the full refname (including refs/...  prefix). This lists detached HEAD (if\npresent) first, then local branches and finally remote-tracking branches. See git-\nconfig(1).\n",
                    "long": "--edit-description"
                },
                {
                    "name": "--points-at <object>",
                    "content": "Only list branches of the given object.\n",
                    "long": "--points-at",
                    "arg": "<object>"
                },
                {
                    "name": "--format <format>",
                    "content": "A string that interpolates %(fieldname) from a branch ref being shown and the object it\npoints at. The format is the same as that of git-for-each-ref(1).\n",
                    "long": "--format",
                    "arg": "<format>"
                }
            ]
        },
        "CONFIGURATION": {
            "content": "pager.branch is only respected when listing branches, i.e., when --list is used or implied.\nThe default is to use a pager. See git-config(1).\n\nEverything above this line in this section isn’t included from the git-config(1)\ndocumentation. The content that follows is the same as what’s found there:\n\nbranch.autoSetupMerge\nTells git branch, git switch and git checkout to set up new branches so that git-pull(1)\nwill appropriately merge from the starting point branch. Note that even if this option is\nnot set, this behavior can be chosen per-branch using the --track and --no-track options.\nThe valid settings are: false — no automatic setup is done; true — automatic setup is\ndone when the starting point is a remote-tracking branch; always —  automatic setup is\ndone when the starting point is either a local branch or remote-tracking branch; inherit\n— if the starting point has a tracking configuration, it is copied to the new branch;\nsimple — automatic setup is done only when the starting point is a remote-tracking branch\nand the new branch has the same name as the remote branch. This option defaults to true.\n\nbranch.autoSetupRebase\nWhen a new branch is created with git branch, git switch or git checkout that tracks\nanother branch, this variable tells Git to set up pull to rebase instead of merge (see\n\"branch.<name>.rebase\"). When never, rebase is never automatically set to true. When\nlocal, rebase is set to true for tracked branches of other local branches. When remote,\nrebase is set to true for tracked branches of remote-tracking branches. When always,\nrebase will be set to true for all tracking branches. See \"branch.autoSetupMerge\" for\ndetails on how to set up a branch to track another branch. This option defaults to never.\n\nbranch.sort\nThis variable controls the sort ordering of branches when displayed by git-branch(1).\nWithout the \"--sort=<value>\" option provided, the value of this variable will be used as\nthe default. See git-for-each-ref(1) field names for valid values.\n\nbranch.<name>.remote\nWhen on branch <name>, it tells git fetch and git push which remote to fetch from or push\nto. The remote to push to may be overridden with remote.pushDefault (for all branches).\nThe remote to push to, for the current branch, may be further overridden by\nbranch.<name>.pushRemote. If no remote is configured, or if you are not on any branch and\nthere is more than one remote defined in the repository, it defaults to origin for\nfetching and remote.pushDefault for pushing. Additionally, .  (a period) is the current\nlocal repository (a dot-repository), see branch.<name>.merge's final note below.\n\nbranch.<name>.pushRemote\nWhen on branch <name>, it overrides branch.<name>.remote for pushing. It also overrides\nremote.pushDefault for pushing from branch <name>. When you pull from one place (e.g.\nyour upstream) and push to another place (e.g. your own publishing repository), you would\nwant to set remote.pushDefault to specify the remote to push to for all branches, and use\nthis option to override it for a specific branch.\n\nbranch.<name>.merge\nDefines, together with branch.<name>.remote, the upstream branch for the given branch. It\ntells git fetch/git pull/git rebase which branch to merge and can also affect git push\n(see push.default). When in branch <name>, it tells git fetch the default refspec to be\nmarked for merging in FETCHHEAD. The value is handled like the remote part of a refspec,\nand must match a ref which is fetched from the remote given by \"branch.<name>.remote\".\nThe merge information is used by git pull (which first calls git fetch) to lookup the\ndefault branch for merging. Without this option, git pull defaults to merge the first\nrefspec fetched. Specify multiple values to get an octopus merge. If you wish to setup\ngit pull so that it merges into <name> from another branch in the local repository, you\ncan point branch.<name>.merge to the desired branch, and use the relative path setting .\n(a period) for branch.<name>.remote.\n\nbranch.<name>.mergeOptions\nSets default options for merging into branch <name>. The syntax and supported options are\nthe same as those of git-merge(1), but option values containing whitespace characters are\ncurrently not supported.\n\nbranch.<name>.rebase\nWhen true, rebase the branch <name> on top of the fetched branch, instead of merging the\ndefault branch from the default remote when \"git pull\" is run. See \"pull.rebase\" for\ndoing this in a non branch-specific manner.\n\nWhen merges (or just m), pass the --rebase-merges option to git rebase so that the local\nmerge commits are included in the rebase (see git-rebase(1) for details).\n\nWhen the value is interactive (or just i), the rebase is run in interactive mode.\n\nNOTE: this is a possibly dangerous operation; do not use it unless you understand the\nimplications (see git-rebase(1) for details).\n\nbranch.<name>.description\nBranch description, can be edited with git branch --edit-description. Branch description\nis automatically added to the format-patch cover letter or request-pull summary.\n",
            "subsections": []
        },
        "EXAMPLES": {
            "content": "Start development from a known tag\n\n$ git clone git://git.kernel.org/pub/scm/.../linux-2.6 my2.6\n$ cd my2.6\n$ git branch my2.6.14 v2.6.14   (1)\n$ git switch my2.6.14\n\n1. This step and the next one could be combined into a single step with\n\"checkout -b my2.6.14 v2.6.14\".\n\nDelete an unneeded branch\n\n$ git clone git://git.kernel.org/.../git.git my.git\n$ cd my.git\n$ git branch -d -r origin/todo origin/html origin/man   (1)\n$ git branch -D test                                    (2)\n\n1. Delete the remote-tracking branches \"todo\", \"html\" and \"man\". The next\nfetch or pull will create them again unless you configure them not to. See\ngit-fetch(1).\n2. Delete the \"test\" branch even if the \"master\" branch (or whichever branch\nis currently checked out) does not have all commits from the test branch.\n\nListing branches from a specific remote\n\n$ git branch -r -l '<remote>/<pattern>'                 (1)\n$ git for-each-ref 'refs/remotes/<remote>/<pattern>'    (2)\n\n1. Using -a would conflate <remote> with any local branches you happen to have\nbeen prefixed with the same <remote> pattern.\n2. for-each-ref can take a wide range of options. See git-for-each-ref(1)\n\nPatterns will normally need quoting.\n",
            "subsections": []
        },
        "NOTES": {
            "content": "1. “Understanding history: What is a branch?”\nfile:///usr/share/doc/git/html/user-manual.html#what-is-a-branch\n\nGit 2.43.0                                   07/02/2025                                GIT-BRANCH(1)",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "git-check-ref-format(1), git-fetch(1), git-remote(1), \u001b[34m“Understanding history: What is a\n\u001b[34mbranch?”[1] in the Git User’s Manual.\n",
            "subsections": []
        },
        "GIT": {
            "content": "Part of the git(1) suite\n",
            "subsections": []
        }
    },
    "summary": "git-branch - List, create, or delete branches",
    "flags": [
        {
            "flag": "-d",
            "long": "--delete",
            "arg": null,
            "description": "Delete a branch. The branch must be fully merged in its upstream branch, or in HEAD if no upstream was set with --track or --set-upstream-to."
        },
        {
            "flag": "-D",
            "long": null,
            "arg": null,
            "description": "Shortcut for --delete --force."
        },
        {
            "flag": "",
            "long": "--create-reflog",
            "arg": null,
            "description": "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 \"<branchname>@{yesterday}\". Note that in non-bare repositories, reflogs are usually enabled by default by the core.logAllRefUpdates config option. The negated form --no-create-reflog only overrides an earlier --create-reflog, but currently does not negate the setting of core.logAllRefUpdates."
        },
        {
            "flag": "-f",
            "long": "--force",
            "arg": null,
            "description": "Reset <branchname> to <start-point>, even if <branchname> exists already. Without -f, git branch refuses to change an existing branch. In combination with -d (or --delete), allow deleting the branch irrespective of its merged status, or whether it even points to a valid commit. In combination with -m (or --move), allow renaming the branch even if the new branch name already exists, the same applies for -c (or --copy). Note that git branch -f <branchname> [<start-point>], even with -f, refuses to change an existing branch <branchname> that is checked out in another worktree linked to the same repository."
        },
        {
            "flag": "-m",
            "long": "--move",
            "arg": null,
            "description": "Move/rename a branch, together with its config and reflog."
        },
        {
            "flag": "-M",
            "long": null,
            "arg": null,
            "description": "Shortcut for --move --force."
        },
        {
            "flag": "-c",
            "long": "--copy",
            "arg": null,
            "description": "Copy a branch, together with its config and reflog."
        },
        {
            "flag": "-C",
            "long": null,
            "arg": null,
            "description": "Shortcut for --copy --force. --color[=<when>] Color branches to highlight current, local, and remote-tracking branches. The value must be always (the default), never, or auto."
        },
        {
            "flag": "",
            "long": "--no-color",
            "arg": null,
            "description": "Turn off branch colors, even when the configuration file gives the default to color output. Same as --color=never."
        },
        {
            "flag": "-i",
            "long": "--ignore-case",
            "arg": null,
            "description": "Sorting and filtering branches are case insensitive."
        },
        {
            "flag": "",
            "long": "--omit-empty",
            "arg": null,
            "description": "Do not print a newline after formatted refs where the format expands to the empty string. --column[=<options>], --no-column Display branch listing in columns. See configuration variable column.branch for option syntax. --column and --no-column without options are equivalent to always and never respectively. This option is only applicable in non-verbose mode."
        },
        {
            "flag": "-r",
            "long": "--remotes",
            "arg": null,
            "description": "List or delete (if used with -d) the remote-tracking branches. Combine with --list to match the optional pattern(s)."
        },
        {
            "flag": "-a",
            "long": "--all",
            "arg": null,
            "description": "List both remote-tracking branches and local branches. Combine with --list to match optional pattern(s)."
        },
        {
            "flag": "-l",
            "long": "--list",
            "arg": null,
            "description": "List branches. With optional <pattern>..., e.g. git branch --list 'maint-*', list only the branches that match the pattern(s)."
        },
        {
            "flag": "",
            "long": "--show-current",
            "arg": null,
            "description": "Print the name of the current branch. In detached HEAD state, nothing is printed."
        },
        {
            "flag": "-v",
            "long": "--verbose",
            "arg": null,
            "description": "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 git remote show <remote>). Note that the current worktree’s HEAD will not have its path printed (it will always be your current directory)."
        },
        {
            "flag": "-q",
            "long": "--quiet",
            "arg": null,
            "description": "Be more quiet when creating or deleting a branch, suppressing non-error messages. --abbrev=<n> In the verbose listing that show the commit object name, show the shortest prefix that is at least <n> hexdigits long that uniquely refers the object. The default value is 7 and can be overridden by the core.abbrev config option."
        },
        {
            "flag": "",
            "long": "--no-abbrev",
            "arg": null,
            "description": "Display the full sha1s in the output listing rather than abbreviating them."
        },
        {
            "flag": "-t",
            "long": null,
            "arg": null,
            "description": "When creating a new branch, set up branch.<name>.remote and branch.<name>.merge 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 git status and git branch -v. Furthermore, it directs git pull without arguments to pull from the upstream when the new branch is checked out. The exact upstream branch is chosen depending on the optional argument: -t, --track, or --track=direct means to use the start-point branch itself as the upstream; --track=inherit means to copy the upstream configuration of the start-point branch. The branch.autoSetupMerge configuration variable specifies how git switch, git checkout and git branch should behave when neither --track nor --no-track are specified: The default option, true, behaves as though --track=direct were given whenever the start-point is a remote-tracking branch. false behaves as if --no-track were given. always behaves as though --track=direct were given. inherit behaves as though --track=inherit were given. simple behaves as though --track=direct were given only when the start-point is a remote-tracking branch and the new branch has the same name as the remote branch. See git-pull(1) and git-config(1) for additional discussion on how the branch.<name>.remote and branch.<name>.merge options are used."
        },
        {
            "flag": "",
            "long": "--no-track",
            "arg": null,
            "description": "Do not set up \"upstream\" configuration, even if the branch.autoSetupMerge configuration variable is set."
        },
        {
            "flag": "",
            "long": "--recurse-submodules",
            "arg": null,
            "description": "THIS OPTION IS EXPERIMENTAL! Causes the current command to recurse into submodules if submodule.propagateBranches is enabled. See submodule.propagateBranches in git-config(1). Currently, only branch creation is supported. When used in branch creation, a new branch <branchname> will be created in the superproject and all of the submodules in the superproject’s <start-point>. In submodules, the branch will point to the submodule commit in the superproject’s <start-point> but the branch’s tracking information will be set up based on the submodule’s branches and remotes e.g. git branch --recurse-submodules topic origin/main 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\"."
        },
        {
            "flag": "",
            "long": "--set-upstream",
            "arg": null,
            "description": "As this option had confusing syntax, it is no longer supported. Please use --track or --set-upstream-to instead. -u <upstream>, --set-upstream-to=<upstream> Set up <branchname>'s tracking information so <upstream> is considered <branchname>'s upstream branch. If no <branchname> is specified, then it defaults to the current branch."
        },
        {
            "flag": "",
            "long": "--unset-upstream",
            "arg": null,
            "description": "Remove the upstream information for <branchname>. If no branch is specified it defaults to the current branch."
        },
        {
            "flag": "",
            "long": "--edit-description",
            "arg": null,
            "description": "Open an editor and edit the text to explain what the branch is for, to be used by various other commands (e.g. format-patch, request-pull, and merge (if enabled)). Multi-line explanations may be used. --contains [<commit>] Only list branches which contain the specified commit (HEAD if not specified). Implies --list. --no-contains [<commit>] Only list branches which don’t contain the specified commit (HEAD if not specified). Implies --list. --merged [<commit>] Only list branches whose tips are reachable from the specified commit (HEAD if not specified). Implies --list. --no-merged [<commit>] Only list branches whose tips are not reachable from the specified commit (HEAD if not specified). Implies --list. <branchname> The name of the branch to create or delete. The new branch name must pass all checks defined by git-check-ref-format(1). Some of these checks may restrict the characters allowed in a branch name. <start-point> 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. <oldbranch> The name of an existing branch to rename. <newbranch> The new name for an existing branch. The same restrictions as for <branchname> apply. --sort=<key> Sort based on the key given. Prefix - to sort in descending order of the value. You may use the --sort=<key> option multiple times, in which case the last key becomes the primary key. The keys supported are the same as those in git for-each-ref. Sort order defaults to the value configured for the branch.sort variable if it exists, or to sorting based on the full refname (including refs/... prefix). This lists detached HEAD (if present) first, then local branches and finally remote-tracking branches. See git- config(1)."
        },
        {
            "flag": "",
            "long": "--points-at",
            "arg": "<object>",
            "description": "Only list branches of the given object."
        },
        {
            "flag": "",
            "long": "--format",
            "arg": "<format>",
            "description": "A string that interpolates %(fieldname) from a branch ref being shown and the object it points at. The format is the same as that of git-for-each-ref(1)."
        }
    ],
    "examples": [
        "Start development from a known tag",
        "$ git clone git://git.kernel.org/pub/scm/.../linux-2.6 my2.6",
        "$ cd my2.6",
        "$ git branch my2.6.14 v2.6.14   (1)",
        "$ git switch my2.6.14",
        "1. This step and the next one could be combined into a single step with",
        "\"checkout -b my2.6.14 v2.6.14\".",
        "Delete an unneeded branch",
        "$ git clone git://git.kernel.org/.../git.git my.git",
        "$ cd my.git",
        "$ git branch -d -r origin/todo origin/html origin/man   (1)",
        "$ git branch -D test                                    (2)",
        "1. Delete the remote-tracking branches \"todo\", \"html\" and \"man\". The next",
        "fetch or pull will create them again unless you configure them not to. See",
        "git-fetch(1).",
        "2. 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.",
        "Listing branches from a specific remote",
        "$ git branch -r -l '<remote>/<pattern>'                 (1)",
        "$ git for-each-ref 'refs/remotes/<remote>/<pattern>'    (2)",
        "1. Using -a would conflate <remote> with any local branches you happen to have",
        "been prefixed with the same <remote> pattern.",
        "2. for-each-ref can take a wide range of options. See git-for-each-ref(1)",
        "Patterns will normally need quoting."
    ],
    "see_also": [
        {
            "name": "git-check-ref-format",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/git-check-ref-format/1/json"
        },
        {
            "name": "git-fetch",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/git-fetch/1/json"
        },
        {
            "name": "git-remote",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/git-remote/1/json"
        }
    ],
    "tldr": {
        "source": "official",
        "description": "Main Git command for working with branches.",
        "examples": [
            {
                "description": "List all branches (local and remote; the current branch is highlighted by `*`)",
                "command": "git branch {{-a|--all}}"
            },
            {
                "description": "List which branches include a specific Git commit in their history",
                "command": "git branch {{-a|--all}} --contains {{commit_hash}}"
            },
            {
                "description": "Show the name of the current branch",
                "command": "git branch --show-current"
            },
            {
                "description": "Create new branch based on the current commit",
                "command": "git branch {{branch_name}}"
            },
            {
                "description": "Create new branch based on a specific commit",
                "command": "git branch {{branch_name}} {{commit_hash}}"
            },
            {
                "description": "Rename a branch (you must switch to a different branch before doing this)",
                "command": "git branch {{-m|--move}} {{old_branch_name}} {{new_branch_name}}"
            },
            {
                "description": "Delete a local branch (you must switch to a different branch before doing this)",
                "command": "git branch {{-d|--delete}} {{branch_name}}"
            },
            {
                "description": "Delete a remote branch",
                "command": "git push {{remote_name}} {{-d|--delete}} {{remote_branch_name}}"
            }
        ]
    }
}