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

在使用Gitoite管理Git库的时候,使用管理员账号对gitolite-admin仓库进行git pull操作的时候报错

[drpeng@srvser gitolite-admin]$ git pull
error: cannot open .git/FETCH_HEAD: Permission denied

看字面意思是.git/FETCH_HEAD这个文件没有权限,进入.git文件夹,查看此文件的权限,确实不对,那就很好解决了:

[drpeng@srvser gitolite-admin]$ cd .git
[drpeng@srvser .git]$ ll -h FETCH_HEAD
总用量 48K
**-rw-r--r--   1 root   root      0 97 2016 FETCH_HEAD**
[drpeng@srvser .git]$ exit
logout
[root@srvser git]# cd /home/drpeng/git-13/gitolite-admin/.git
[root@srvser .git]# chown -R drpeng.drpeng FETCH_HEAD
[root@srvser .git]# su - drpeng
[root@srvser git]# cd /home/drpeng/git-13/gitolite-admin/
[drpeng@srvser git-13]$ cd gitolite-admin/
[drpeng@srvser gitolite-admin]$ git pull
remote: Counting objects: 509, done.
remote: Compressing objects: 100% (404/404), done.
remote: Total 499 (delta 125), reused 0 (delta 0)
Receiving objects: 100% (499/499), 53.32 KiB, done.
Resolving deltas: 100% (125/125), done.

以上,问题解决~

你可能感兴趣的:(Git)