A container sees files owned by another user ID
CommonThe repository was cloned on the host, or by a CI step, as one user, and is mounted into a container that runs git as root or a different user. The owner IDs differ, so Git refuses.
Confirm
stat -c '%u %U' . id -u
Two different numbers: the directory's owner and you. (On macOS: stat -f '%u %Su' .)
Fix
- Run the container as the owner of the files: docker run --user "$(id -u):$(id -g)" … so they match.
- Or mark the mounted path safe inside the container, for that one path: git config --global --add safe.directory /workspace/repo (or git -c safe.directory=/workspace/repo … for a single command).
- In a Dockerfile that builds from a copied repository, chown the files to the build user, or add the path to safe.directory in the image's global config.
git config --global --add safe.directory /workspace/repo
Use the exact path from the error. Per command instead: git -c safe.directory=/workspace/repo status