Menu

Git "detected dubious ownership in repository": Fix It in Docker and CI Without Trusting Everything
📰

Git "detected dubious ownership in repository": Fix It in Docker and CI Without Trusting Everything

DEV Community: cicd·Libme·2 days ago
#PWafDz51
#devtocicd#devto#dev#directory#config
Reading 0:00
15s threshold

The error means the user running Git does not own the repository directory, and since Git 2.35.2 Git refuses to run there as a security measure. The quick fix is git config --global --add safe.directory <path> , but in containers and CI the better fix is usually to make the UIDs match, and a blanket safe.directory '*' is only acceptable on throwaway machines.

What does the error actually look like?

fatal: detected dubious ownership in repository at '/workspace' To add an exception for this directory, call:

git config --global --add safe.directory /workspace

Enter fullscreen mode

Exit fullscreen mode

You tend to meet it in four places: a bind-mounted source directory inside Docker, a CI job that runs inside a container image, a repo checked out by one user and used by another (a deploy user versus root, say), and network or Windows-shared drives.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.