Problem
When opening a WSL project in a JetBrains IDE running on Windows, Git operations fail with:
fatal: detected dubious ownership in repository at '<path>'
Cause
The IDE uses the Windows Git executable (git.exe) instead of the Git binary from the WSL distribution. The Windows Git binary sees the WSL filesystem path as owned by a different user, which triggers the safe.directory check and aborts the operation.
The IDE does not auto-detect or switch to the WSL Git binary when the project is located on the WSL filesystem (\\wsl$\<distro>\... or \\wsl.localhost\<distro>\...).
Resolution
Option 1: Point the IDE at the WSL Git binary (recommended)
- Open Settings (Ctrl+Alt+S) | Version Control | Git.
- In the Path to Git executable field, enter the path to the Git binary inside the WSL distribution, for example:
\\wsl$\<distro-name>\usr\bin\git. - Click OK.
To apply the same setting to all newly created projects:
- Open File | New Projects Setup | Settings for New Projects....
- Repeat the steps above.
Option 2: Mark all directories as safe (global workaround)
Run the following command in a terminal to disable the safe-directory check for every repository:
git config --global safe.directory '*'
This bypasses the ownership check for all repositories. It does not switch the IDE to the WSL Git binary.
Comments
0 comments
Please sign in to leave a comment.