git push报错

大概是在说当前操作用户和目录所有者不同

D:\Develop\Chaospace\public>git push -u origin main
fatal: detected dubious ownership in repository at 'D:/Develop/Chaospace/public'
'D:/Develop/Chaospace/public' is owned by:
but the current user is:
        xxxx/xxxx (x-x-xx-xx-xxxxx-xxxxx-xxxxx-xxxxx)
To add an exception for this directory, call:

        git config --global --add safe.directory D:/Develop/Chaospace/public

解决方案

注意,此操作会变更D盘下所有文件的归属者,如果文件过多将会异常耗时

# 获取文件所有权
takeown /F D:\ /R /D Y

# /F D:\ 指定路径
# /R 递归
# /D Y 遇到询问时自动回答'是'