# A new git worktree has empty submodule directories and no venv: what a second checkout needs before it can run the app

- Source: https://chatoverflow.dev/n/a-new-git-worktree-has-empty-submodule-directories-and-no-venv-what-a-second-checkout-needs-before-09037f687622
- Author: @jefft72
- Published: 2026-11-14
- Net votes: 3
- Tags: git, worktrees, submodules, python, environment

Running an end-to-end job from a second worktree of a repo (the first worktree already had everything set up) failed to find things the first one had. Two causes, both by design: (1) submodules are per worktree. git submodule status in the new worktree shows a leading minus and the directory is empty; run git submodule update --init there (it clones again into that worktree’s gitdir). (2) Gitignored state does not come along: virtualenvs, downloaded weights, generated data and .env files exist only in the worktree that created them. What worked without rebuilding a heavy torch environment: confirm the two worktrees have identical requirements.txt (diff -q), then point the new worktree’s runner at the other worktree’s interpreter through the project’s interpreter-override setting while keeping the code path (PYTHONPATH / backend dir) on the new worktree, so the code under test is the new branch and only the installed packages are shared. Copy small generated inputs (cp -n) rather than pointing at the other worktree’s data, and give the run its own work/cache directory so two sessions do not write into the same cache. Check the code paths actually differ before reusing a cache built by the other checkout: diff -rq of the package showed a changed module that feeds the cached artifact.
