Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallYes: a new Git worktree needs its own dependency installation when the project relies on node_modules. Git checks out tracked files into a separate working directory; it does not copy ignored local dependencies from another worktree. Install from the new worktree’s own manifest and lockfile, then use package-manager caching or setup automation to make that step less tedious.
Why a new worktree does not include node_modules
A Git worktree is an additional working directory attached to the same repository, not another branch sharing the same checkout. Git describes the feature as allowing a repository to support multiple working trees so you can check out more than one branch at a time (Git worktree documentation).
As an Amazon Associate I earn from qualifying purchases.
The worktrees share repository data, but each has its own checked-out files and some worktree-specific state. For example, each worktree has its own HEAD. By contrast, node_modules is normally local working-tree content and is commonly ignored by Git. A new checkout therefore does not recreate it.
To create another worktree, you might run:
git worktree add ../feature feature-branch
Git checks out tracked files in ../feature. If the project needs dependencies, install them there using that branch’s package manifest and lockfile.
#1 Best Overall
Install dependencies using the project’s package manager
First check which package manager and lockfile the project uses. Use the repository’s established command rather than choosing one based only on habit. With npm and a committed package-lock.json, npm ci is an option for a clean, lockfile-based install:
cd ../feature
npm ci
If the project uses another package manager or a different lockfile, follow its existing workflow. The important point is that installation happens in the new worktree and uses that worktree’s dependency declarations.
Rank #2
Reduce the repeated cost without sharing a dependency tree
Use a package manager’s shared package store
Separate node_modules directories do not necessarily require separate full copies of every package’s contents. The practical guidance for pnpm describes a content-addressable store that can deduplicate package data while each worktree retains its own dependency arrangement (Git Worktree and node_modules guide; Git Worktree FAQ). Actual disk use and install time depend on the project, package manager, platform, and cache state; the shared store is not a guaranteed performance figure.
Automate the install step
A small shell function or project script can create the worktree and run the install command your team already uses. It should detect or explicitly follow the repository’s authoritative lockfile, rather than guessing when multiple package-manager files are present. Automation removes a reminder from the workflow, but it does not make the branches’ dependencies interchangeable.
Rank #3
Avoid automatically copying environment files such as .env as part of this setup. They may contain secrets or configuration that should differ between branches.
Why a shared node_modules symlink is a fragile default
Linking one worktree’s node_modules into another can seem convenient when both branches have identical dependency requirements. But if a branch changes its manifest or lockfile, the linked tree may no longer reflect what that branch declares. The mismatch can be quiet: commands may resolve installed packages even though the worktree’s lockfile specifies something else. Keep separate dependency trees unless you have verified that the requirements and relevant install conditions match, and can keep them matched as branches change.
What npm workspaces do—and do not do
npm workspaces let a project manage local packages beneath a top-level package and link those local packages during installation (npm workspaces documentation). They are not a mechanism that automatically shares one node_modules directory between separate Git worktrees. Treat each worktree as its own checkout and install according to its own repository setup.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Scan for outdated or missing drivers - takes under a minute3Clear out junk files and repair common Windows errorsQuick Recap
Best Value
Choose a workflow that preserves dependency correctness
| Approach | Dependency correctness | Disk use | Setup friction | Failure clarity |
|---|---|---|---|---|
| Install separately in each worktree | Uses that worktree’s manifest and lockfile. | Each worktree has its own dependency arrangement; package contents may be cached or deduplicated depending on the package manager. | Requires an install step unless automated. | Missing dependencies are usually apparent when a command cannot resolve them. |
| Use a package manager with a shared store | Each worktree can still have its own dependency arrangement. | Identical package data may be deduplicated; actual savings vary. | Requires using and configuring the package manager’s normal workflow. | Worktrees remain distinct, reducing the chance that one branch silently uses another branch’s dependency tree. |
| Symlink one worktree’s node_modules into another | Reliable only while dependency requirements and relevant install conditions match. | Avoids maintaining a separate linked directory, though the exact storage outcome depends on the setup. | Can avoid a repeated install initially. | Can hide a mismatch after manifests or lockfiles diverge. |
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




