{"thread":{"id":"66405","subject":"\"git -C other_repo\" returns wrong GIT_DIR and GIT_COMMON_DIR when run via alias in worktree","startedAt":"2026-09-28T13:38:41Z","lastAt":"2026-09-28T13:38:41Z","messageCount":1,"participants":["jumps_dollies_9s@icloud.com"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"553465","messageId":"85B2D383-8519-4A76-8DED-459067060B61@icloud.com","threadId":"66405","inReplyTo":null,"subject":"\"git -C other_repo\" returns wrong GIT_DIR and GIT_COMMON_DIR when run via alias in worktree","fromName":"","fromEmail":"jumps_dollies_9s@icloud.com","sentAt":"2026-09-28T13:38:22Z","receivedAt":"2026-09-28T13:38:41Z","isPatch":false,"body":"Hello,\nI’ve discovered an interesting and likely very niche bug. When using \"git -C other_repo …” from the worktree, the values of GIT_DIR and GIT_COMMON_DIR reflect those of the worktree, not the other repo, but only when run via an alias. If run directly, then GIT_DIR and GIT_COMMON_DIR reflect the expected values for the other repo.\n\nThis has knock-on effects, notably when using “git -C submodule_path restore” in an alias, it copies the contents of the parent repository.\n\nUsing “git -C other_repo …” from the original clone returns the correct values for GIT_DIR and GIT_COMMON_DIR. This occurs only with worktrees.\n\nI’ve collected a reproduction into a single script\nhttps://gist.github.com/MayaBarriaultRT/76d864f005bcff2fccb02444c48a3343\n\nI’ve reproduced this with Git v2.52.0 on AlmaLinux 9.7, v2.54.0 on macOS 26.4, and v2.55.0 built from source using ubuntu:26.04 Docker image.\n\nMaya Barriault"}]}