A hook (or a script it calls) runs `git -C /srv/other-repo pull`, which fails with `fatal: not a git repository: '.git'` or operates on the wrong repo.
AdvancedTroubleshootingConfig, Line Endings, Files and Platform Quirks
Answer
Likely causes → Git exports GIT_DIR (and in some hooks GIT_INDEX_FILE, GIT_WORK_TREE) to hook processes. Child Git commands inherit them and ignore -C/the current directory, so they target the original repo or a relative .git that does not exist there.
Diagnose → Log the environment in the hook: env | grep ^GIT_ > /tmp/hook-env.txt.
Fix → Clear the variables before touching another repo:
#!/usr/bin/env bash
unset GIT_DIR GIT_WORK_TREE GIT_INDEX_FILE
git -C /srv/other-repo pull --ff-only
In a bare-repo post-receive deploy hook, set them deliberately instead: git --work-tree=/srv/app --git-dir="$PWD" checkout -f main.
Prevent → Treat hooks as running inside Git's environment; always reset GIT_* variables before invoking Git elsewhere.
More on Config, Line Endings, Files and Platform Quirks
`warning: in the working copy of 'app.sh', LF will be replaced by CRLF the next time Git touches it`Beginner`git diff` shows `old mode 100755` / `new mode 100644` for hundreds of files with no content change.BeginnerCloning on Windows fails with `error: unable to create file src/very/deep/.../component.test.ts: Filename too long`.BeginnerYou renamed `header.tsx` to `Header.tsx` on macOS. Locally everything builds, but Linux CI fails with `Module not found: Can't resolve './components/Header'`.IntermediateCheckout on Windows fails with `error: invalid path 'logs/2024-01-01T10:00:00.log'` (or `'docs/aux.md'`) and `fatal: unable to checkout working tree`.IntermediateClone prints `warning: the following paths have collided (e.g. case-sensitive paths on a case-insensitive filesystem) and only one from the same colliding group is in the working tree:`Intermediate