I hit the same issue with upgrade to PyCharm 2024.3.5 when using WSL2. I tried the solutions above and had no luck. Looking at the processes running in the VM, PyCharm has sudo
'd itself as root, and so my fix was:
sudo git config --global --add safe.directory /path/to/my code
This makes sense because root
does not own the files.