Git worktree gives one repository multiple working directories. It is useful when an urgent fix arrives while the current checkout contains unfinished changes: the fix gets its own branch, index and files without requiring you to stash the original task first. Linked worktrees still share repository data and ordinary branch references. They are neither independent backups nor security boundaries for scripts. The original workflow and local fixture checks are dated November 5, 2026. The configuration-scope addendum below uses the official Git worktree and config manuals checked on November 21, 2026; the earlier status-manual check is not represented as new. There are no affiliate links or paid-product recommendations.
Begin in the existing repository with git --version, git status --short --untracked-files=all and git worktree list. Record the current branch and the files that need preserving. The commands below assume a repository with an existing commit, a new branch name and an unused sibling directory; adapt the names to your project. A second checkout starts from committed history, not from the unstaged, staged or untracked files currently being edited. If the fix requires those unfinished changes, decide explicitly how to transfer them rather than expecting worktree creation to copy them.
For an independent fix based on the current commit, run: git worktree add -b hotfix/login ../project-hotfix HEAD. The explicit branch and start point avoid relying on a directory-derived branch name. HEAD means the current checkout’s commit, not automatically the latest remote main branch. If the required base is another branch or commit, inspect and name that revision instead. A remote-tracking reference reflects your last fetch, not a guarantee of current server state. The -b option refuses an existing branch name; do not substitute -B merely to make an error disappear, because -B can reset that branch.
Confirm the result with git worktree list and git -C ../project-hotfix status --short --branch --untracked-files=all. Use git -C with the intended directory or deliberately change into it before editing, building or committing. If a branch already exists and is not checked out elsewhere, git worktree add ../project-hotfix hotfix/login can use it. Git normally refuses a branch already checked out in another worktree. Treat that refusal as a useful coordination signal: choose a separate branch or use the checkout already holding it, rather than routinely overriding the protection with --force.
For read-only investigation or a temporary build from the current commit, git worktree add --detach ../project-inspect HEAD creates a detached checkout. If investigation turns into changes you want to keep, give the work an explicit branch before treating the directory as disposable. Removing a directory is not a plan for retaining detached commits. Branches and repository data are shared, so a worktree is also not a place to experiment casually with branch deletion or repository-wide configuration that could affect other tasks.
The separate directory does not supply independent databases, cloud credentials, network ports or production services. Ignored environment files and local dependency directories are not copied from the original checkout as part of the committed tree. Follow the project’s setup instructions and use appropriate test services; do not assume two development servers can bind the same port. Before running unfamiliar project scripts, understand their external side effects. This is a workflow distinction, not a claim that Git isolates or audits those scripts.
Before cleanup, inspect the target with git -C ../project-hotfix status --short --untracked-files=all --ignored. Ordinary git status does not show ignored paths by default. That omission matters for local environment files, scratch exports or other valuable data excluded from version control. A clean-looking default status is not proof that the directory contains nothing worth saving. Inspect and preserve needed ignored files outside the worktree, using appropriate protection for secrets; never commit credentials just to make cleanup easier. Also inspect submodule state separately if the repository uses submodules.
Only after the intended changes are committed or otherwise preserved, and local files have been checked, use git worktree remove ../project-hotfix. This removes the linked working directory, not its branch. Retaining the branch does not preserve uncommitted or ignored files. The manual says ordinary removal refuses worktrees with tracked modifications or untracked files; do not interpret that guard as a general backup guarantee. Avoid --force in routine cleanup. The main worktree cannot be removed this way, and worktrees containing submodules have additional restrictions. Stop and inspect a refusal instead of escalating to a recursive directory deletion.
Moving and removing are different operations. For an ordinary linked tree without submodules, use git worktree move ../project-hotfix ../project-hotfix-renamed, then check git worktree list and the new path’s status. The manual excludes moving the main worktree or linked worktrees containing submodules with this command. If a linked directory was moved manually and still exists, git worktree repair ../project-hotfix-renamed can reconnect administrative information to that location. Repair is for broken location metadata; it cannot reconstruct deleted working files or replace a backup.
If the main repository has moved, the manual directs running git worktree repair from the relocated main repository to reconnect linked trees. If both the main and linked directories moved manually, run repair from the main repository and supply the new linked paths. Verify the intended repository and every path first. Do not edit .git pointers speculatively when the documented repair command matches the situation. After repair, inspect both the worktree list and each affected checkout’s status before resuming development.
A missing worktree path may be an unplugged drive or an unavailable network mount rather than abandoned work. While the worktree is registered, git worktree lock --reason "External drive may be offline" ../project-hotfix protects its administrative entry from pruning and also prevents normal movement or removal. The lock is administrative protection, not encryption, a filesystem lock or a backup of the drive. Use git worktree unlock ../project-hotfix only when you intend to permit those operations again. Reconnect the actual device and inspect it before deciding that its worktree is stale.
Prune is not a substitute for remove or repair. Git worktree prune removes stale administrative information for missing working trees; it does not remove an existing checkout directory as a normal cleanup workflow. Start with git worktree prune --dry-run --verbose to see the proposed cleanup. A preview listing is not proof that the missing files are unwanted: first distinguish an offline mount, a moved directory that needs repair and a genuinely abandoned path. Do not add an aggressive expiry or force flag simply to make the list empty.
Use a short handoff record for every parallel task: repository location, linked directory, branch or detached commit, intended base commit, setup requirements and owner. Before removing the checkout, add where committed work will be reviewed or merged and where any necessary local files were preserved. This record is especially useful when an IDE, terminal and automation all use different working directories. A branch name alone does not tell you whether there are valuable unstaged files in its current checkout.
YNIX exercised these examples in a new local Git 2.43.0 repository with artificial files, not in a reader’s project. The fixture confirmed that a second checkout left the original unfinished file untouched, duplicate branch checkout was refused, ordinary status hid an ignored file, and an untracked file blocked ordinary removal. It also exercised lock/unlock, supported move, repair after a manual move, a prune preview and clean removal with the branch retained. All fixture-local files were preserved outside the removed tree first. These checks support the illustrated workflow; they are not a test of every Git version, IDE, submodule arrangement, network filesystem or recovery scenario.
Configuration scope — separate files do not mean separate Git settings. The worktree manual says the repository configuration file is shared across worktrees by default. Running a repository-local configuration write after changing into a linked checkout can therefore affect the other checkouts too. A different terminal directory does not make remote, identity or other repository settings private to that task. Inspect the effective setting and its source before changing it; do not use a worktree as an isolation boundary for configuration experiments.
The --worktree option has an important prerequisite. The config manual says it reads or writes the worktree-specific config.worktree file only when extensions.worktreeConfig is enabled. Without that extension, --worktree behaves like --local. Consequently, adding --worktree to a write command is not by itself proof that only the linked checkout will change. This is a documented fallback, not a new Git defect or a behavior we measured across every installed version.
Use a read-only scope check first. In the intended checkout, run git config --show-origin --show-scope --get-all extensions.worktreeConfig and inspect any values and their origins; an absent value is not evidence that the extension is enabled. For the specific setting you are investigating, use the same read-only form with that key, for example git config --show-origin --show-scope --get-all user.name. The flags report where values came from and their scope. An unset key can produce no value and a nonzero exit status; do not turn that result into an automatic write or a claim that the repository is broken. Inspect only the needed keys and keep output local: configuration values and file paths can contain personal or sensitive information.
Enabling worktree-specific configuration is a repository migration, not a routine setup step for every parallel task. The worktree manual warns that older Git versions refuse repositories using this extension. It also requires moving core.worktree and core.bare settings from the common configuration into the main worktree configuration if they exist; sparse-checkout settings deserve review too. Before choosing that migration, inventory the Git versions used by terminals, IDEs and automation, preserve the existing configuration and follow the current official migration instructions. Do not paste an extension-enabling command into an unknown repository merely to silence a scope warning. This guide does not change your configuration or promise compatibility with your toolchain.
Configuration handoff worksheet — add five fields to the task record: the intended checkout path, the exact setting under discussion, its observed origin and scope, whether worktree-specific configuration is enabled, and which other checkouts or tools could be affected. If isolation is not established, pause the proposed setting change and coordinate it as shared repository work. After an intentionally approved change, verify the relevant setting from each affected checkout rather than assuming the current terminal tells the whole story. This is an original read-only inspection and coordination worksheet, not a tested configuration-migration procedure.
The decision rule is simple: add for a second checkout, move for a planned relocation, repair for a surviving directory with broken links, lock for a temporarily unavailable location, remove for a carefully checked finished checkout, and prune for genuinely stale metadata. When the situation is unclear, preserve the files and inspect the paths before acting. The original checkout and a linked checkout share enough state that good path discipline matters more than having another directory.
Editorial transparency: this source-based configuration addendum was prepared with AI assistance and reviewed by Hans for YNIX. No new Git-version compatibility, migration or recovery test was performed on November 21; the artificial Git 2.43.0 fixture results described above remain the November 5 checks.