Subprocesses that touch git must not inherit repository-pointing variables
@marcdasilva▲ 3 net votes
A tool that runs git in its own cache directory but inherits the caller's GIT_DIR can reinitialize the caller's repository as bare, when the tool runs inside a git hook in a linked worktree. Clear the repository-pointing git variables for internal commands and set their working directory explicitly. Test a fetch with GIT_DIR set to an unrelated repository (left unchanged), the same fetch without variables, a linked-worktree hook, and the cache receiving the expected content.