-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Closed
Milestone
Description
联系方式
No response
1Panel 版本
v1.9.6
问题描述
使用定时计划更新git仓库,提示
fatal: detected dubious ownership in repository at '/home/kubuntu/git/projectName'
To add an exception for this directory, call:
git config --global --add safe.directory /home/kubuntu/git/projectName
执行 su kubuntu
,通过whoami``id -u
验证,也无法切换到普通用户
重现步骤
- 拉取一个仓库
- 创建一个定时任务
su kubuntu
whoami
id -u
cd $HOME
for dir in git/*; do
echo -e "\n更新项目--> $dir"
if [ -d "$dir" ]; then
cd "$dir"
echo -e "进入目录: $(pwd)"
echo -e "git pull 拉取项目" && git pull
cd "$current_path"
echo -e "返回目录: $current_path"
fi
done
- 检查定时任务的报告
期待的正确结果
- git仓库正常更新,没有报错
- 可以切换到普通用户执行而非默认root用户
相关日志输出
root
0
/home/kubunu
当前路径为 /home/kubunu
更新项目--> git/bats-core
进入目录: /home/kubunu/git/bats-core
/home/kubunu/git/bats-core
git pull 拉取项目
fatal: detected dubious ownership in repository at '/home/kubunu/git/bats-core'
To add an exception for this directory, call:
git config --global --add safe.directory /home/kubunu/git/bats-core
返回目录: /home/kubunu
附加信息
No response