-- 创造无限可能

git提交应为权限问题报错Detected dubious ownership in repository

2026-07-30 18:51:14
11 人浏览 0 人点赞
有用,点赞支持一下

报错信息:

Detected dubious ownership in repository at ‘/www/wwwroot/tooi.cn/.git’ To add an exception for this directory, call: git config —global —add safe.directory /www/wwwroot/tooi.cn/.git Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.

我的git地址是:ssh://git@xxx.xxx.xxx.xxx/www/wwwroot/tooi.cn/.git

www/wwwroot/tooi.cn目录是 root 建的,你现在用普通用户(www / git / 你当前 SSH 用户)去操作,Git 出于安全考虑直接拒绝。

第一步设置目录为信任目录
git config —global —add safe.directory /www/wwwroot/tooi.cn

第二步:
改成 git 用户和它的用户组
chown -R git:git /www/wwwroot/tooi.cn