解决fatal: could not create work tree dir ‘xxxx’: Permission denied问题

最近刚刚用Linux,同时也刚刚用git,使用的时候出现了一下问题,记录一下
输入:

git clone ssh://git@192.168.xxx.xxx:10022/os/st.git -b dev

报错:

fatal: could not create work tree dir ‘xxxx’: Permission denied

报这个错误的原因就是正在写入或者克隆git仓库的目录没有写入的权限。

解决:

$ cd ../    (回退到当前目录的上一级)
$ sudo chmod o+w dirname  (dirname为当前目录的名字)

但是输入上面内容时,又报错

xxx is not in the sudoers file.This incident will be reported

这是因为你当前的用户是没有xxx的权限的

解决:

su root
chmod u+w /etc/sudoers
vi /etc/sudoers
chmod u+w /etc/sudoers

说明:

  1. 先转到root用户下
  2. 添加sudo文件的写权限
  3. 编辑sudoers文件【找到这行 root ALL=(ALL) ALL,在他下面添加xxx ALL=(ALL) ALL (这里的xxx是你的用户名)】
  4. 撤销sudoers文件写权限

备注:

这里说下你可以sudoers添加下面四行中任意一条
youuser ALL=(ALL) ALL
%youuser ALL=(ALL) ALL
youuser ALL=(ALL) NOPASSWD: ALL
%youuser ALL=(ALL) NOPASSWD: ALL

第一行:允许用户youuser执行sudo命令(需要输入密码).
第二行:允许用户组youuser里面的用户执行sudo命令(需要输入密码).
第三行:允许用户youuser执行sudo命令,并且在执行的时候不输入密码.
第四行:允许用户组youuser里面的用户执行sudo命令,并且在执行的时候不输入密码.

posted @   XZshijian  阅读(603)  评论(0编辑  收藏  举报  
相关博文:
阅读排行:
· winform 绘制太阳,地球,月球 运作规律
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
点击右上角即可分享
微信分享提示