Interview Prep/Git & GitHub/GitHub, Actions and Pull Request Issues

A container job fails on any Git command with `fatal: detected dubious ownership in repository at '/__w/app/app'`.

IntermediateTroubleshootingGitHub, Actions and Pull Request Issues
Answer

Likely causes → Since Git 2.35.2 (CVE-2022-24765), Git refuses to work in a repo owned by a different user. The workspace was checked out by the runner user, but the container runs as root (or vice versa). Same issue on shared servers and Docker volume mounts.

Diagnose →

id -u; stat -c '%u %n' /__w/app/app
git --version

Fix → Mark that path as safe, inside the same user context that runs Git:

git config --global --add safe.directory /__w/app/app
# or, in a throwaway container only:
git config --global --add safe.directory '*'

Recent actions/checkout sets this for you; the problem appears when later steps run as another user or in another container.

Prevent → Run containers with the same UID as the workspace owner, and avoid the '*' wildcard on shared hosts.

All Git & GitHub questions Roadmap: Git & GitHub

More on GitHub, Actions and Pull Request Issues