git pull报错error: cannot open .git/FETCH_HEAD: Permission denied

报错如图:

siqi@aliyun-sh-001:~/data-analysis$ git pull 
hint: Pulling without specifying how to reconcile divergent branches is
hint: discouraged. You can squelch this message by running one of the following
hint: commands sometime before your next pull:
hint: 
hint:   git config pull.rebase false  # merge (the default strategy)
hint:   git config pull.rebase true   # rebase
hint:   git config pull.ff only       # fast-forward only
hint: 
hint: You can replace "git config" with "git config --global" to set a default
hint: preference for all repositories. You can also pass --rebase, --no-rebase,
hint: or --ff-only on the command line to override the configured default per
hint: invocation.
error: cannot open .git/FETCH_HEAD: Permission denied

问题分析:

.git/FETCH_HEAD权限没有和用户权限匹配。通过如下命令可以查看该文件权限:

siqi@aliyun-sh-001:~/data-analysis$ ls -lh .git/FETCH_HEAD
-rw-r--r-- 1 root root 0 Mar 26 15:14 .git/FETCH_HEAD

最终解决方案:

赋予该文件夹下所有文件和该用户同等权限

siqi@aliyun-sh-001:~/data-analysis$ sudo chown -R siqi:siqi .git
siqi@aliyun-sh-001:~/data-analysis$ ls -lh .git/FETCH_HEAD
-rw-r--r-- 1 siqi siqi 2.5K Mar 26 15:20 .git/FETCH_HEAD
siqi@aliyun-sh-001:~/data-analysis$ git fetch --all
Fetching origin
remote: Enumerating objects: 12, done.
remote: Counting objects: 100% (12/12), done.
remote: Compressing objects: 100% (12/12), done.
remote: Total 12 (delta 3), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (12/12), 5.19 KiB | 1.73 MiB/s, done.
From gitlab.com:jiangyin-12345/data-analysis
   8d623e5..cfa7eee  feat-full-download-special-subject -> origin/feat-full-download-special-subject
  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值