解决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命令,并且在执行的时候不输入密码.

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值