Git Status Shows Worktree Folders as Untracked
Prepared and checked using AI. Sources are linked in the article.
If git status shows worktree folders as untracked, the agent worktrees are probably inside the main checkout. From that checkout, Git sees each nested folder as a path it does not track. You can keep status clean by placing agent worktrees beside the main checkout, or by ignoring a dedicated directory if they must stay inside it. Git status reports untracked paths that are not ignored; it does not hide a folder merely because that folder is another worktree.
Why a linked worktree appears there
Git lets a repository have a main worktree and additional linked worktrees at paths you choose. A linked worktree has its own checkout and a .git file that connects it to repository metadata. That connection does not make its directory a tracked part of the main checkout.
For example, suppose /projects/acme is the main checkout and an agent’s linked worktree is /projects/acme/.agent-worktrees/fix-cache. Running git status from /projects/acme may show .agent-worktrees/ as untracked. Running it from fix-cache reports that worktree’s own changes. These are two views of different working directories, even though the worktrees belong to the same repository. For more on that relationship, see Git worktrees explained.
The distinction matters when deciding what to fix. An untracked directory entry in the main checkout does not, by itself, mean the agent’s branch is uncommitted, detached, or broken. It means the directory’s location falls under the main checkout and no ignore rule is hiding it there. Keep the agent’s worktree intact while you choose a location or an ignore rule.
Check the location before changing anything
From the main checkout, run:
git rev-parse --show-toplevel
git worktree list
git status --short
git rev-parse --show-toplevel prints the current worktree’s root. Compare that path with those in git worktree list. If an agent path begins with the main checkout’s path plus a child directory, it is nested. In short status, ?? .agent-worktrees/ means the directory is untracked from the main checkout’s point of view.
Next, check the agent worktree itself:
cd .agent-worktrees/fix-cache
git rev-parse --show-toplevel
git status --short
Use the first command’s output to confirm that you entered the intended worktree. The second status check tells you whether that worktree has changes that need attention before you move or remove it. Return to the main checkout before following the commands below.
If the path in git worktree list is already outside the main checkout, inspect the path shown by git status --short more closely. It may be a separate directory with a similar name, rather than the linked worktree you expected. Do not remove either directory based on its name alone.
Keep agent worktrees beside the checkout
A sibling directory is a straightforward arrangement when you control where new worktrees are created. For example, from /projects/acme:
mkdir -p ../acme-agent-worktrees
git worktree add -b agent/fix-cache ../acme-agent-worktrees/fix-cache
The new worktree sits at /projects/acme-agent-worktrees/fix-cache, outside /projects/acme. The main checkout cannot list that sibling as one of its untracked child directories. The agent still has a separate working directory and branch. Choose a distinct branch name for each agent; Git’s worktree command normally refuses to check out a branch that is already checked out in another worktree.
For an existing nested linked worktree, check its status first, then move it with Git:
mkdir -p ../acme-agent-worktrees
git worktree move .agent-worktrees/fix-cache ../acme-agent-worktrees/fix-cache
git worktree list
git status --short
git worktree move updates the link between the worktree and its repository metadata. A manual filesystem move can leave that connection pointing to the old path; git worktree repair exists for reconnecting worktrees moved outside Git. Moving may be unavailable for a locked linked worktree or one containing submodules, so read the error before trying another method. If an agent session or editor uses the old absolute path, update that path before resuming it. See resuming an agent session in the right worktree for the related location problem.
Ignore a dedicated nested directory
If a tool or team workflow requires agent worktrees under the main checkout, give them a directory used only for that purpose. Then choose where the ignore rule belongs:
| Rule location | Use it when | Trade-off |
|---|---|---|
.git/info/exclude | The path is a personal arrangement for this repository. | The rule is not committed with the project. |
Root .gitignore | Everyone should use the same nested directory. | The rule becomes a project change when committed. |
Git reads patterns from both .gitignore and the repository’s info/exclude file. In either location, use this pattern for the example directory:
/.agent-worktrees/
The leading slash anchors the pattern to the root of a worktree, and the trailing slash targets a directory. Use the actual name of your dedicated directory. Keep the rule narrow: ignoring a general path such as /work/ could conceal unrelated new files that should be reviewed or committed.
To find the exclude file Git uses for this repository, run:
git rev-parse --git-path info/exclude
Add the pattern to the printed file if you want the local rule. For a shared rule, add it to the root .gitignore and review that change like any other project change. A .gitignore rule only affects paths that are not already tracked; adding a rule is not a way to remove tracked project files from the index.
Verify the result from the main checkout:
git check-ignore -v .agent-worktrees/fix-cache
git status --short
git status --short --ignored
git check-ignore -v identifies the matching pattern and its source. The normal status output should no longer list the directory as untracked; --ignored lets you confirm that Git is hiding it by an ignore rule. If the check reports no match, inspect the directory name, the rule’s location, and any more specific negation patterns before broadening the rule.
An ignore rule changes what the main checkout reports. It does not remove an agent worktree, save its changes, or make its branch available elsewhere. Continue to inspect the agent worktree’s own status when reviewing its work.
Hide untracked paths for one status check
For a temporary view of tracked changes, use:
git status --short --untracked-files=no
This suppresses all untracked paths in that status output, including legitimate new source files. It is useful for a quick inspection, but it does not fix a nested worktree layout. Avoid making it your default if you rely on status to notice files an agent has created but not added.
Remove a worktree you no longer need
If the agent’s task is finished, inspect and preserve any changes you need, including ignored files. From inside the agent worktree, run:
git status --short --ignored
Ordinary status omits ignored files. Git’s removal implementation checks ordinary status and then recursively deletes the worktree directory, including ignored files. Preserve any ignored files you need before proceeding, even if ordinary status shows a clean worktree.
Return to the main checkout, then use the registered path:
git worktree list
git worktree remove .agent-worktrees/fix-cache
git worktree list
git status --short
git worktree remove normally requires a clean worktree. If it refuses, return to that worktree and account for its modified or untracked files; forcing removal can discard work. git worktree prune serves a different purpose: it clears stale administrative records for worktree directories that are already missing. It is not the command for deleting an active agent checkout. For a fuller sequence, see cleaning up stale AI agent worktrees.
Be especially careful with cleanup commands issued from the main checkout. git clean removes untracked paths, and -x also includes ignored paths. An ignore rule that quiets status is therefore no protection against a clean command that includes ignored files. Use git worktree remove for a linked worktree you intend to retire, after checking the work inside it.
Where Parallel Code fits
Parallel Code is our free, open-source (MIT) desktop app for macOS and Linux. It runs several AI coding agents in parallel, each isolated in its own git worktree, and provides a diff-first review surface. If a worktree appears as untracked in your main checkout, use the path and ignore checks above to identify how that worktree is laid out.
Frequently asked questions
Is an untracked worktree folder a Git error?
Usually it is a path-layout issue: the linked worktree sits inside the main checkout, so the main checkout reports its directory as untracked. Check git worktree list and run status inside the agent worktree before deciding whether anything needs repair.
Should I add the agent worktree directory to Git?
No, if your aim is to keep a separate agent checkout. Place it outside the main checkout or ignore a dedicated nested directory, then review and commit the agent’s changes from within its own worktree.
Should the ignore rule go in .gitignore or .git/info/exclude?
Use .gitignore when the team intends to share the directory convention. Use .git/info/exclude when the nested path is only part of your local setup; either way, verify the rule with git check-ignore -v.
Will ignoring the folder hide files inside the agent worktree?
It hides that directory from the main checkout’s ordinary status output. Enter the agent worktree and run git status there to review its files; do not use the main checkout’s clean status as evidence that the agent’s work is complete.