Since the Git 2.35.2 security release (April 2022, fixing CVE-2022-24765), Git refuses to run in a repository whose working directory is owned by a different user than the one running Git. The error is 'fatal: detected dubious ownership in repository at ...' followed by a hint about safe.directory. This bites constantly in CI containers that run as root over a checkout owned by another UID, in Docker bind mounts on Linux, and on shared build agents.
Confirm with 'git status' as the affected user and compare 'stat -c %u .git' against 'id -u'. The supported fix is to add the path to the multi-valued safe.directory config, for example 'git config --global --add safe.directory /path/to/repo'. The value '*' disables the check entirely and should only be used inside a disposable container. Note that safe.directory is only read from system and global config, never from the repository's own config, precisely so an attacker-controlled repo cannot whitelist itself.