0
点赞
收藏
分享

微信扫一扫

mac insufficient permission for adding an object to repository

程序员伟杰 2022-08-11 阅读 79


今天在使用git pull的时候出现了下面的错误:

remote: Enumerating objects: 15, done.
remote: Counting objects: 100% (15/15), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 9 (delta 6), reused 9 (delta 6), pack-reused 0
error: insufficient permission for adding an object to repository database .git/objects
fatal: failed to write object
fatal: unpack-objects failed

解决方法

cd .git
ls -al
sudo chown -R eric:staff * # eric是我的用户名:staff是我的组
cd ..
git pull

示例

EtCampusDoc git:(master) cd .git
➜ .git git:(master) ls
COMMIT_EDITMSG ORIG_HEAD description info packed-refs
FETCH_HEAD branches hooks logs refs
HEAD config index objects
➜ .git git:(master) ls -al
total 56
drwxr-xr-x 16 eric staff 512 Mar 12 23:31 .
drwxr-xr-x 15 eric staff 480 Mar 12 21:50 ..
-rw-r--r-- 1 eric staff 17 Mar 12 22:17 COMMIT_EDITMSG
-rw-r--r-- 1 eric staff 0 Mar 12 23:26 FETCH_HEAD
-rw-r--r-- 1 root staff 23 Mar 12 22:18 HEAD
-rw-r--r-- 1 eric staff 41 Mar 12 22:28 ORIG_HEAD
drwxr-xr-x 2 eric staff 64 Jan 22 23:31 branches
-rw-r--r-- 1 eric staff 313 Jan 22 23:32 config
-rw-r--r-- 1 eric staff 73 Jan 22 23:31 description
drwxr-xr-x 11 eric staff 352 Jan 22 23:31 hooks
-rw-r--r-- 1 root staff 3205 Mar 12 22:18 index
drwxr-xr-x 3 eric staff 96 Jan 22 23:31 info
drwxr-xr-x 4 eric staff 128 Jan 22 23:32 logs
drwxr-xr-x 174 eric staff 5568 Mar 12 22:16 objects
-rw-r--r-- 1 eric staff 974 Jan 22 23:32 packed-refs
drwxr-xr-x 5 eric staff 160 Jan 22 23:32 refs

➜  .git git:(master) chmod -R eric:staff *
chmod: Invalid file mode: eric:staff
➜ .git git:(master) sudo chmod -R eric:staff *
chmod: Invalid file mode: eric:staff
➜ .git git:(master) sudo chown -R eric:staff *
➜ .git git:(master) cd ..
➜ EtCampusDoc git:(master) git pull
remote: Enumerating objects: 15, done.
remote: Counting objects: 100% (15/15), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 9 (delta 6), reused 9 (delta 6), pack-reused 0
Unpacking objects: 100% (9/9), done.
From https://github.com/yingzhox/EtCampusDoc
4cbc3cd..bcc4df0 master -> origin/master
137d1a6..fa65b77 gh-pages -> origin/gh-pages
Updating 4cbc3cd..bcc4df0
Fast-forward
main.apib | 39 ++++++++++++++-------------------------
1 file changed, 14 insertions(+), 25 deletions(-)

成功更新

参考文献

[1]. How to Fix GIT PUSH ERROR: insufficient permission for adding an object to repository database .git/objects [OSX YOSEMITE]. ​​https://medium.com/@darkrubyist/how-to-fix-git-push-error-insufficient-permission-for-adding-an-object-to-repository-database-git-53d7dc9649e2​​

 

举报

相关推荐

0 条评论