错误场景如下:
liudui@MacBookM1Pro layout-gin % git add cmd/server/recv.go
error: insufficient permission for adding an object to repository database .git/objects
error: cmd/server/recv.go: failed to insert into database
error: unable to index file 'cmd/server/recv.go'
fatal: updating files failed
尝试解决
chmod 777 .git
chown -R liudui:group .git
一般情况下 chmod
777 命令即可解决问题,如果不行的话就再尝试赋予目录用户权限也就是 chown
再次执行测试
liudui@MacBookM1Pro layout-gin % git add .
liudui@MacBookM1Pro layout-gin % git st
On branch master
Your branch is up to date with 'origin/master'.
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: cmd/server/recv.go
完成!