Git error fatal: unsafe repository solution

Git error fatal:  unsafe  repository xxx is owned by someone else
because git has upgraded the version and added new directory security restrictions. It will cause the .git file to not be found in regular git operations or in various editors

Error details:

fatal: unsafe repository ('D:/代码练习/11-vue/vue-router' is owned by someone else)
To add an exception for this directory, call:

        git config --global --add safe.directory 'D:/code practice/11-vue/vue-router'

Solution

        Use the suggested code in the cmd window here

        git config --global --add safe.directory D:/code practice/11-vue/vue-router

*Notice

        Remove the quotes ' ' in the prompt code position

After executing this command, the git add . test found that it can be used normally 

Note : If not resolved, other methods such as:

Method 1: git config --global --add safe.directory "*" is not suitable for computers with multiple users, otherwise there will be security problems

Method 2: File directory - right click - properties - security - advanced - owner - change to your current user.

Method 3: Find the git- gui.exe in the installation directory , right-click-properties-compatibility-run the program as an administrator-tick.

Method 4: Delete the .git folder and run git init in the terminal to reinitialize

You can also try, the essence is the problem of insufficient user rights caused by git upgrade.

 

Guess you like

Origin blog.csdn.net/weixin_46669844/article/details/128192682