{
    "mode": "man",
    "parameter": "git-worktree",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/git-worktree/1/json",
    "generated": "2026-09-02T13:46:01Z",
    "synopsis": "git worktree add [-f] [--detach] [--checkout] [--lock [--reason <string>]]\n[--orphan] [(-b | -B) <new-branch>] <path> [<commit-ish>]\ngit worktree list [-v | --porcelain [-z]]\ngit worktree lock [--reason <string>] <worktree>\ngit worktree move <worktree> <new-path>\ngit worktree prune [-n] [-v] [--expire <expire>]\ngit worktree remove [-f] <worktree>\ngit worktree repair [<path>...]\ngit worktree unlock <worktree>",
    "sections": {
        "NAME": {
            "content": "git-worktree - Manage multiple working trees\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "git worktree add [-f] [--detach] [--checkout] [--lock [--reason <string>]]\n[--orphan] [(-b | -B) <new-branch>] <path> [<commit-ish>]\ngit worktree list [-v | --porcelain [-z]]\ngit worktree lock [--reason <string>] <worktree>\ngit worktree move <worktree> <new-path>\ngit worktree prune [-n] [-v] [--expire <expire>]\ngit worktree remove [-f] <worktree>\ngit worktree repair [<path>...]\ngit worktree unlock <worktree>\n\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Manage multiple working trees attached to the same repository.\n\nA git repository can support multiple working trees, allowing you to check out more than one\nbranch at a time. With git worktree add a new working tree is associated with the repository,\nalong with additional metadata that differentiates that working tree from others in the same\nrepository. The working tree, along with this metadata, is called a \"worktree\".\n\nThis new worktree is called a \"linked worktree\" as opposed to the \"main worktree\" prepared by\ngit-init(1) or git-clone(1). A repository has one main worktree (if it’s not a bare\nrepository) and zero or more linked worktrees. When you are done with a linked worktree,\nremove it with git worktree remove.\n\nIn its simplest form, git worktree add <path> automatically creates a new branch whose name\nis the final component of <path>, which is convenient if you plan to work on a new topic. For\ninstance, git worktree add ../hotfix creates new branch hotfix and checks it out at path\n../hotfix. To instead work on an existing branch in a new worktree, use git worktree add\n<path> <branch>. On the other hand, if you just plan to make some experimental changes or do\ntesting without disturbing existing development, it is often convenient to create a throwaway\nworktree not associated with any branch. For instance, git worktree add -d <path> creates a\nnew worktree with a detached HEAD at the same commit as the current branch.\n\nIf a working tree is deleted without using git worktree remove, then its associated\nadministrative files, which reside in the repository (see \"DETAILS\" below), will eventually\nbe removed automatically (see gc.worktreePruneExpire in git-config(1)), or you can run git\nworktree prune in the main or any linked worktree to clean up any stale administrative files.\n\nIf the working tree for a linked worktree is stored on a portable device or network share\nwhich is not always mounted, you can prevent its administrative files from being pruned by\nissuing the git worktree lock command, optionally specifying --reason to explain why the\nworktree is locked.\n",
            "subsections": []
        },
        "COMMANDS": {
            "content": "add <path> [<commit-ish>]\nCreate a worktree at <path> and checkout <commit-ish> into it. The new worktree is linked\nto the current repository, sharing everything except per-worktree files such as HEAD,\nindex, etc. As a convenience, <commit-ish> may be a bare \"-\", which is synonymous with\n@{-1}.\n\nIf <commit-ish> is a branch name (call it <branch>) and is not found, and neither -b nor\n-B nor --detach are used, but there does exist a tracking branch in exactly one remote\n(call it <remote>) with a matching name, treat as equivalent to:\n\n$ git worktree add --track -b <branch> <path> <remote>/<branch>\n\nIf the branch exists in multiple remotes and one of them is named by the\ncheckout.defaultRemote configuration variable, we’ll use that one for the purposes of\ndisambiguation, even if the <branch> isn’t unique across all remotes. Set it to e.g.\ncheckout.defaultRemote=origin to always checkout remote branches from there if <branch>\nis ambiguous but exists on the origin remote. See also checkout.defaultRemote in git-\nconfig(1).\n\nIf <commit-ish> is omitted and neither -b nor -B nor --detach used, then, as a\nconvenience, the new worktree is associated with a branch (call it <branch>) named after\n$(basename <path>). If <branch> doesn’t exist, a new branch based on HEAD is\nautomatically created as if -b <branch> was given. If <branch> does exist, it will be\nchecked out in the new worktree, if it’s not checked out anywhere else, otherwise the\ncommand will refuse to create the worktree (unless --force is used).\n\nIf <commit-ish> is omitted, neither --detach, or --orphan is used, and there are no valid\nlocal branches (or remote branches if --guess-remote is specified) then, as a\nconvenience, the new worktree is associated with a new orphan branch named <branch>\n(after $(basename <path>) if neither -b or -B is used) as if --orphan was passed to the\ncommand. In the event the repository has a remote and --guess-remote is used, but no\nremote or local branches exist, then the command fails with a warning reminding the user\nto fetch from their remote first (or override by using -f/--force).\n\nlist\nList details of each worktree. The main worktree is listed first, followed by each of the\nlinked worktrees. The output details include whether the worktree is bare, the revision\ncurrently checked out, the branch currently checked out (or \"detached HEAD\" if none),\n\"locked\" if the worktree is locked, \"prunable\" if the worktree can be pruned by the prune\ncommand.\n\nlock\nIf a worktree is on a portable device or network share which is not always mounted, lock\nit to prevent its administrative files from being pruned automatically. This also\nprevents it from being moved or deleted. Optionally, specify a reason for the lock with\n--reason.\n\nmove\nMove a worktree to a new location. Note that the main worktree or linked worktrees\ncontaining submodules cannot be moved with this command. (The git worktree repair\ncommand, however, can reestablish the connection with linked worktrees if you move the\nmain worktree manually.)\n\nprune\nPrune worktree information in $GITDIR/worktrees.\n\nremove\nRemove a worktree. Only clean worktrees (no untracked files and no modification in\ntracked files) can be removed. Unclean worktrees or ones with submodules can be removed\nwith --force. The main worktree cannot be removed.\n\nrepair [<path>...]\nRepair worktree administrative files, if possible, if they have become corrupted or\noutdated due to external factors.\n\nFor instance, if the main worktree (or bare repository) is moved, linked worktrees will\nbe unable to locate it. Running repair in the main worktree will reestablish the\nconnection from linked worktrees back to the main worktree.\n\nSimilarly, if the working tree for a linked worktree is moved without using git worktree\nmove, the main worktree (or bare repository) will be unable to locate it. Running repair\nwithin the recently-moved worktree will reestablish the connection. If multiple linked\nworktrees are moved, running repair from any worktree with each tree’s new <path> as an\nargument, will reestablish the connection to all the specified paths.\n\nIf both the main worktree and linked worktrees have been moved manually, then running\nrepair in the main worktree and specifying the new <path> of each linked worktree will\nreestablish all connections in both directions.\n\nunlock\nUnlock a worktree, allowing it to be pruned, moved or deleted.\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "",
            "subsections": [
                {
                    "name": "-f, --force",
                    "content": "By default, add refuses to create a new worktree when <commit-ish> is a branch name and\nis already checked out by another worktree, or if <path> is already assigned to some\nworktree but is missing (for instance, if <path> was deleted manually). This option\noverrides these safeguards. To add a missing but locked worktree path, specify --force\ntwice.\n\nmove refuses to move a locked worktree unless --force is specified twice. If the\ndestination is already assigned to some other worktree but is missing (for instance, if\n<new-path> was deleted manually), then --force allows the move to proceed; use --force\ntwice if the destination is locked.\n\nremove refuses to remove an unclean worktree unless --force is used. To remove a locked\nworktree, specify --force twice.\n",
                    "flag": "-f",
                    "long": "--force"
                },
                {
                    "name": "-b <new-branch>, -B <new-branch>",
                    "content": "With add, create a new branch named <new-branch> starting at <commit-ish>, and check out\n<new-branch> into the new worktree. If <commit-ish> is omitted, it defaults to HEAD. By\ndefault, -b refuses to create a new branch if it already exists.  -B overrides this\nsafeguard, resetting <new-branch> to <commit-ish>.\n",
                    "flag": "-B",
                    "arg": "<new-branch>"
                },
                {
                    "name": "-d, --detach",
                    "content": "With add, detach HEAD in the new worktree. See \"DETACHED HEAD\" in git-checkout(1).\n\n--[no-]checkout\nBy default, add checks out <commit-ish>, however, --no-checkout can be used to suppress\ncheckout in order to make customizations, such as configuring sparse-checkout. See\n\"Sparse checkout\" in git-read-tree(1).\n\n--[no-]guess-remote\nWith worktree add <path>, without <commit-ish>, instead of creating a new branch from\nHEAD, if there exists a tracking branch in exactly one remote matching the basename of\n<path>, base the new branch on the remote-tracking branch, and mark the remote-tracking\nbranch as \"upstream\" from the new branch.\n\nThis can also be set up as the default behaviour by using the worktree.guessRemote config\noption.\n\n--[no-]track\nWhen creating a new branch, if <commit-ish> is a branch, mark it as \"upstream\" from the\nnew branch. This is the default if <commit-ish> is a remote-tracking branch. See --track\nin git-branch(1) for details.\n",
                    "flag": "-d",
                    "long": "--detach"
                },
                {
                    "name": "--lock",
                    "content": "Keep the worktree locked after creation. This is the equivalent of git worktree lock\nafter git worktree add, but without a race condition.\n",
                    "long": "--lock"
                },
                {
                    "name": "-n, --dry-run",
                    "content": "With prune, do not remove anything; just report what it would remove.\n",
                    "flag": "-n",
                    "long": "--dry-run"
                },
                {
                    "name": "--orphan",
                    "content": "With add, make the new worktree and index empty, associating the worktree with a new\norphan/unborn branch named <new-branch>.\n",
                    "long": "--orphan"
                },
                {
                    "name": "--porcelain",
                    "content": "With list, output in an easy-to-parse format for scripts. This format will remain stable\nacross Git versions and regardless of user configuration. It is recommended to combine\nthis with -z. See below for details.\n",
                    "long": "--porcelain"
                },
                {
                    "name": "-z",
                    "content": "Terminate each line with a NUL rather than a newline when --porcelain is specified with\nlist. This makes it possible to parse the output when a worktree path contains a newline\ncharacter.\n",
                    "flag": "-z"
                },
                {
                    "name": "-q, --quiet",
                    "content": "With add, suppress feedback messages.\n",
                    "flag": "-q",
                    "long": "--quiet"
                },
                {
                    "name": "-v, --verbose",
                    "content": "With prune, report all removals.\n\nWith list, output additional information about worktrees (see below).\n",
                    "flag": "-v",
                    "long": "--verbose"
                },
                {
                    "name": "--expire <time>",
                    "content": "With prune, only expire unused worktrees older than <time>.\n\nWith list, annotate missing worktrees as prunable if they are older than <time>.\n",
                    "long": "--expire",
                    "arg": "<time>"
                },
                {
                    "name": "--reason <string>",
                    "content": "With lock or with add --lock, an explanation why the worktree is locked.\n\n<worktree>\nWorktrees can be identified by path, either relative or absolute.\n\nIf the last path components in the worktree’s path is unique among worktrees, it can be\nused to identify a worktree. For example if you only have two worktrees, at /abc/def/ghi\nand /abc/def/ggg, then ghi or def/ghi is enough to point to the former worktree.\n",
                    "long": "--reason",
                    "arg": "<string>"
                }
            ]
        },
        "REFS": {
            "content": "When using multiple worktrees, some refs are shared between all worktrees, but others are\nspecific to an individual worktree. One example is HEAD, which is different for each\nworktree. This section is about the sharing rules and how to access refs of one worktree from\nanother.\n\nIn general, all pseudo refs are per-worktree and all refs starting with refs/ are shared.\nPseudo refs are ones like HEAD which are directly under $GITDIR instead of inside\n$GITDIR/refs. There are exceptions, however: refs inside refs/bisect, refs/worktree and\nrefs/rewritten are not shared.\n\nRefs that are per-worktree can still be accessed from another worktree via two special paths,\nmain-worktree and worktrees. The former gives access to per-worktree refs of the main\nworktree, while the latter to all linked worktrees.\n\nFor example, main-worktree/HEAD or main-worktree/refs/bisect/good resolve to the same value\nas the main worktree’s HEAD and refs/bisect/good respectively. Similarly, worktrees/foo/HEAD\nor worktrees/bar/refs/bisect/bad are the same as $GITCOMMONDIR/worktrees/foo/HEAD and\n$GITCOMMONDIR/worktrees/bar/refs/bisect/bad.\n\nTo access refs, it’s best not to look inside $GITDIR directly. Instead use commands such as\ngit-rev-parse(1) or git-update-ref(1) which will handle refs correctly.\n",
            "subsections": []
        },
        "CONFIGURATION FILE": {
            "content": "By default, the repository config file is shared across all worktrees. If the config\nvariables core.bare or core.worktree are present in the common config file and\nextensions.worktreeConfig is disabled, then they will be applied to the main worktree only.\n\nIn order to have worktree-specific configuration, you can turn on the worktreeConfig\nextension, e.g.:\n\n$ git config extensions.worktreeConfig true\n\n\nIn this mode, specific configuration stays in the path pointed by git rev-parse --git-path\nconfig.worktree. You can add or update configuration in this file with git config --worktree.\nOlder Git versions will refuse to access repositories with this extension.\n\nNote that in this file, the exception for core.bare and core.worktree is gone. If they exist\nin $GITDIR/config, you must move them to the config.worktree of the main worktree. You may\nalso take this opportunity to review and move other configuration that you do not want to\nshare to all worktrees:\n\n•   core.worktree should never be shared.\n\n•   core.bare should not be shared if the value is core.bare=true.\n\n•   core.sparseCheckout should not be shared, unless you are sure you always use sparse\ncheckout for all worktrees.\n\nSee the documentation of extensions.worktreeConfig in git-config(1) for more details.\n",
            "subsections": []
        },
        "DETAILS": {
            "content": "Each linked worktree has a private sub-directory in the repository’s $GITDIR/worktrees\ndirectory. The private sub-directory’s name is usually the base name of the linked worktree’s\npath, possibly appended with a number to make it unique. For example, when\n$GITDIR=/path/main/.git the command git worktree add /path/other/test-next next creates the\nlinked worktree in /path/other/test-next and also creates a $GITDIR/worktrees/test-next\ndirectory (or $GITDIR/worktrees/test-next1 if test-next is already taken).\n\nWithin a linked worktree, $GITDIR is set to point to this private directory (e.g.\n/path/main/.git/worktrees/test-next in the example) and $GITCOMMONDIR is set to point back\nto the main worktree’s $GITDIR (e.g. /path/main/.git). These settings are made in a .git\nfile located at the top directory of the linked worktree.\n\nPath resolution via git rev-parse --git-path uses either $GITDIR or $GITCOMMONDIR\ndepending on the path. For example, in the linked worktree git rev-parse --git-path HEAD\nreturns /path/main/.git/worktrees/test-next/HEAD (not /path/other/test-next/.git/HEAD or\n/path/main/.git/HEAD) while git rev-parse --git-path refs/heads/master uses $GITCOMMONDIR\nand returns /path/main/.git/refs/heads/master, since refs are shared across all worktrees,\nexcept refs/bisect, refs/worktree and refs/rewritten.\n\nSee gitrepository-layout(5) for more information. The rule of thumb is do not make any\nassumption about whether a path belongs to $GITDIR or $GITCOMMONDIR when you need to\ndirectly access something inside $GITDIR. Use git rev-parse --git-path to get the final\npath.\n\nIf you manually move a linked worktree, you need to update the gitdir file in the entry’s\ndirectory. For example, if a linked worktree is moved to /newpath/test-next and its .git file\npoints to /path/main/.git/worktrees/test-next, then update\n/path/main/.git/worktrees/test-next/gitdir to reference /newpath/test-next instead. Better\nyet, run git worktree repair to reestablish the connection automatically.\n\nTo prevent a $GITDIR/worktrees entry from being pruned (which can be useful in some\nsituations, such as when the entry’s worktree is stored on a portable device), use the git\nworktree lock command, which adds a file named locked to the entry’s directory. The file\ncontains the reason in plain text. For example, if a linked worktree’s .git file points to\n/path/main/.git/worktrees/test-next then a file named\n/path/main/.git/worktrees/test-next/locked will prevent the test-next entry from being\npruned. See gitrepository-layout(5) for details.\n\nWhen extensions.worktreeConfig is enabled, the config file\n.git/worktrees/<id>/config.worktree is read after .git/config is.\n",
            "subsections": []
        },
        "LIST OUTPUT FORMAT": {
            "content": "The worktree list command has two output formats. The default format shows the details on a\nsingle line with columns. For example:\n\n$ git worktree list\n/path/to/bare-source            (bare)\n/path/to/linked-worktree        abcd1234 [master]\n/path/to/other-linked-worktree  1234abc  (detached HEAD)\n\n\nThe command also shows annotations for each worktree, according to its state. These\nannotations are:\n\n•   locked, if the worktree is locked.\n\n•   prunable, if the worktree can be pruned via git worktree prune.\n\n$ git worktree list\n/path/to/linked-worktree    abcd1234 [master]\n/path/to/locked-worktree    acbd5678 (brancha) locked\n/path/to/prunable-worktree  5678abc  (detached HEAD) prunable\n\n\nFor these annotations, a reason might also be available and this can be seen using the\nverbose mode. The annotation is then moved to the next line indented followed by the\nadditional information.\n\n$ git worktree list --verbose\n/path/to/linked-worktree              abcd1234 [master]\n/path/to/locked-worktree-no-reason    abcd5678 (detached HEAD) locked\n/path/to/locked-worktree-with-reason  1234abcd (brancha)\nlocked: worktree path is mounted on a portable device\n/path/to/prunable-worktree            5678abc1 (detached HEAD)\nprunable: gitdir file points to non-existent location\n\n\nNote that the annotation is moved to the next line if the additional information is\navailable, otherwise it stays on the same line as the worktree itself.\n",
            "subsections": [
                {
                    "name": "Porcelain Format",
                    "content": "The porcelain format has a line per attribute. If -z is given then the lines are terminated\nwith NUL rather than a newline. Attributes are listed with a label and value separated by a\nsingle space. Boolean attributes (like bare and detached) are listed as a label only, and are\npresent only if the value is true. Some attributes (like locked) can be listed as a label\nonly or with a value depending upon whether a reason is available. The first attribute of a\nworktree is always worktree, an empty line indicates the end of the record. For example:\n\n$ git worktree list --porcelain\nworktree /path/to/bare-source\nbare\n\nworktree /path/to/linked-worktree\nHEAD abcd1234abcd1234abcd1234abcd1234abcd1234\nbranch refs/heads/master\n\nworktree /path/to/other-linked-worktree\nHEAD 1234abc1234abc1234abc1234abc1234abc1234a\ndetached\n\nworktree /path/to/linked-worktree-locked-no-reason\nHEAD 5678abc5678abc5678abc5678abc5678abc5678c\nbranch refs/heads/locked-no-reason\nlocked\n\nworktree /path/to/linked-worktree-locked-with-reason\nHEAD 3456def3456def3456def3456def3456def3456b\nbranch refs/heads/locked-with-reason\nlocked reason why is locked\n\nworktree /path/to/linked-worktree-prunable\nHEAD 1233def1234def1234def1234def1234def1234b\ndetached\nprunable gitdir file points to non-existent location\n\n\nUnless -z is used any \"unusual\" characters in the lock reason such as newlines are escaped\nand the entire reason is quoted as explained for the configuration variable core.quotePath\n(see git-config(1)). For Example:\n\n$ git worktree list --porcelain\n...\nlocked \"reason\\nwhy is locked\"\n...\n\n"
                }
            ]
        },
        "EXAMPLES": {
            "content": "You are in the middle of a refactoring session and your boss comes in and demands that you\nfix something immediately. You might typically use git-stash(1) to store your changes away\ntemporarily, however, your working tree is in such a state of disarray (with new, moved, and\nremoved files, and other bits and pieces strewn around) that you don’t want to risk\ndisturbing any of it. Instead, you create a temporary linked worktree to make the emergency\nfix, remove it when done, and then resume your earlier refactoring session.\n\n$ git worktree add -b emergency-fix ../temp master\n$ pushd ../temp\n# ... hack hack hack ...\n$ git commit -a -m 'emergency fix for boss'\n$ popd\n$ git worktree remove ../temp\n\n",
            "subsections": []
        },
        "BUGS": {
            "content": "Multiple checkout in general is still experimental, and the support for submodules is\nincomplete. It is NOT recommended to make multiple checkouts of a superproject.\n",
            "subsections": []
        },
        "GIT": {
            "content": "Part of the git(1) suite\n\nGit 2.43.0                                   07/02/2025                              GIT-WORKTREE(1)",
            "subsections": []
        }
    },
    "summary": "git-worktree - Manage multiple working trees",
    "flags": [
        {
            "flag": "-f",
            "long": "--force",
            "arg": null,
            "description": "By default, add refuses to create a new worktree when <commit-ish> is a branch name and is already checked out by another worktree, or if <path> is already assigned to some worktree but is missing (for instance, if <path> was deleted manually). This option overrides these safeguards. To add a missing but locked worktree path, specify --force twice. move refuses to move a locked worktree unless --force is specified twice. If the destination is already assigned to some other worktree but is missing (for instance, if <new-path> was deleted manually), then --force allows the move to proceed; use --force twice if the destination is locked. remove refuses to remove an unclean worktree unless --force is used. To remove a locked worktree, specify --force twice."
        },
        {
            "flag": "-B",
            "long": null,
            "arg": "<new-branch>",
            "description": "With add, create a new branch named <new-branch> starting at <commit-ish>, and check out <new-branch> into the new worktree. If <commit-ish> is omitted, it defaults to HEAD. By default, -b refuses to create a new branch if it already exists. -B overrides this safeguard, resetting <new-branch> to <commit-ish>."
        },
        {
            "flag": "-d",
            "long": "--detach",
            "arg": null,
            "description": "With add, detach HEAD in the new worktree. See \"DETACHED HEAD\" in git-checkout(1). --[no-]checkout By default, add checks out <commit-ish>, however, --no-checkout can be used to suppress checkout in order to make customizations, such as configuring sparse-checkout. See \"Sparse checkout\" in git-read-tree(1). --[no-]guess-remote With worktree add <path>, without <commit-ish>, instead of creating a new branch from HEAD, if there exists a tracking branch in exactly one remote matching the basename of <path>, base the new branch on the remote-tracking branch, and mark the remote-tracking branch as \"upstream\" from the new branch. This can also be set up as the default behaviour by using the worktree.guessRemote config option. --[no-]track When creating a new branch, if <commit-ish> is a branch, mark it as \"upstream\" from the new branch. This is the default if <commit-ish> is a remote-tracking branch. See --track in git-branch(1) for details."
        },
        {
            "flag": "",
            "long": "--lock",
            "arg": null,
            "description": "Keep the worktree locked after creation. This is the equivalent of git worktree lock after git worktree add, but without a race condition."
        },
        {
            "flag": "-n",
            "long": "--dry-run",
            "arg": null,
            "description": "With prune, do not remove anything; just report what it would remove."
        },
        {
            "flag": "",
            "long": "--orphan",
            "arg": null,
            "description": "With add, make the new worktree and index empty, associating the worktree with a new orphan/unborn branch named <new-branch>."
        },
        {
            "flag": "",
            "long": "--porcelain",
            "arg": null,
            "description": "With list, output in an easy-to-parse format for scripts. This format will remain stable across Git versions and regardless of user configuration. It is recommended to combine this with -z. See below for details."
        },
        {
            "flag": "-z",
            "long": null,
            "arg": null,
            "description": "Terminate each line with a NUL rather than a newline when --porcelain is specified with list. This makes it possible to parse the output when a worktree path contains a newline character."
        },
        {
            "flag": "-q",
            "long": "--quiet",
            "arg": null,
            "description": "With add, suppress feedback messages."
        },
        {
            "flag": "-v",
            "long": "--verbose",
            "arg": null,
            "description": "With prune, report all removals. With list, output additional information about worktrees (see below)."
        },
        {
            "flag": "",
            "long": "--expire",
            "arg": "<time>",
            "description": "With prune, only expire unused worktrees older than <time>. With list, annotate missing worktrees as prunable if they are older than <time>."
        },
        {
            "flag": "",
            "long": "--reason",
            "arg": "<string>",
            "description": "With lock or with add --lock, an explanation why the worktree is locked. <worktree> Worktrees can be identified by path, either relative or absolute. If the last path components in the worktree’s path is unique among worktrees, it can be used to identify a worktree. For example if you only have two worktrees, at /abc/def/ghi and /abc/def/ggg, then ghi or def/ghi is enough to point to the former worktree."
        }
    ],
    "examples": [
        "You are in the middle of a refactoring session and your boss comes in and demands that you",
        "fix something immediately. You might typically use git-stash(1) to store your changes away",
        "temporarily, however, your working tree is in such a state of disarray (with new, moved, and",
        "removed files, and other bits and pieces strewn around) that you don’t want to risk",
        "disturbing any of it. Instead, you create a temporary linked worktree to make the emergency",
        "fix, remove it when done, and then resume your earlier refactoring session.",
        "$ git worktree add -b emergency-fix ../temp master",
        "$ pushd ../temp",
        "# ... hack hack hack ...",
        "$ git commit -a -m 'emergency fix for boss'",
        "$ popd",
        "$ git worktree remove ../temp"
    ],
    "see_also": [],
    "tldr": {
        "source": "official",
        "description": "Manage multiple working trees attached to the same repository.",
        "examples": [
            {
                "description": "Add a new worktree directory for a branch with the same name (created if missing)",
                "command": "git worktree add {{branch}}"
            },
            {
                "description": "Create a new directory with the specified branch checked out into it",
                "command": "git worktree add {{path/to/directory}} {{branch}}"
            },
            {
                "description": "Create a new directory with a new branch checked out into it",
                "command": "git worktree add {{path/to/directory}} -b {{new_branch}}"
            },
            {
                "description": "List all the working directories (including the primary one)",
                "command": "git worktree list"
            },
            {
                "description": "Move an existing worktree to a new location",
                "command": "git worktree move {{path/to/worktree}} {{new/path}}"
            },
            {
                "description": "Remove a worktree directory and its metadata (only if it has no uncommitted changes)",
                "command": "git worktree remove {{path/to/worktree}}"
            },
            {
                "description": "Remove metadata for a worktree directory that's been manually deleted",
                "command": "git worktree prune"
            }
        ]
    }
}