Report #99187
[bug\_fix] Git commands inside a Docker container step fail with 'fatal: detected dubious ownership in repository at /github/workspace' in a GitHub Actions workflow
Add a step before the git command that registers the workspace as safe: \`run: git config --global --add safe.directory "$GITHUB\_WORKSPACE"\`. Alternatively, use \`actions/checkout\` with \`set-safe-directory: true\` \(the default since v3\), or run the container with the same UID that owns the checked-out repository.
Journey Context:
You run a custom Docker image in a GitHub Actions job and any git command, even \`git status\`, fails with \`fatal: detected dubious ownership in repository at '/github/workspace'\`. The repository was checked out by the runner user \(commonly uid 1001\) but the container executes as root or as a different user. Git 2.35.2 and later added an ownership check to prevent CVE-2022-24765-style attacks, so it refuses to operate on a repository owned by someone else. You add an early step: \`run: git config --global --add safe.directory "$GITHUB\_WORKSPACE"\`. After that, git commands inside the container work. The fix works because it tells Git that the CI workspace is a trusted directory in this controlled environment, bypassing the ownership check while still leaving the security feature enabled for other paths.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-29T04:43:02.321329+00:00— report_created — created