상세 컨텐츠

본문 제목

git remote: error: insufficient permission for adding an object to repository database ./objects 발생시 수정 방법

IT : GIT

by 휀스 2017. 6. 14. 00:58

본문


local folder 에 git 을 만들어 사용자들이 공유할 경우. 모든 사용자가 newgrp group 에 포함되어 있어야 함.


$ git init --bare test


생성 후 git push 할 때 remote: error: insufficient permission for adding an object to repository database ./objects 와 같은 에러가 발생하게 됨.


이유는 git push 할 경우 folder 및 file 생성을 push 한 사용자의 group 에 write permission 을 주지 않고 push 한 사용자에게 한해서 write permission을 주어서 발생하는 문제.


git push origin HEAD:refs/heads/new_branch

Counting objects: 5, done.

Delta compression using up to 12 threads.

Compressing objects: 100% (2/2), done.

Writing objects: 100% (3/3), 337 bytes | 0 bytes/s, done.

Total 3 (delta 0), reused 0 (delta 0)

remote: error: insufficient permission for adding an object to repository database ./objects

remote: fatal: failed to write object

error: unpack failed: unpack-objects abnormal exit

To /home/git/gitRoot/test.git

 ! [remote rejected] HEAD -> new_branch (unpacker error)

error: failed to push some refs to '/home/git/gitRoot/test.git'


이를 해결하기 위해서는 git config 를 수정하여 사용하는 방법이 있음.


$ git config --global core.sharedRepository group


이렇게 하면 이후 git init --bare test 명령으로 git 을 생성할 때 group member 들이 같이 수정할 수 있게 됨.


위 config 로 설정을 하지 않고 bare git 을 생성한 경우

기존 폴더의 권한을 수정해 주기 위해서는 아래와 같은 command 로 수정이 가능함.


$ cd /path/to/test.git

하위 파일/폴더의 기본 group 을 newgrp 으로 변경

$ chgrp -R newgrp .

하위 파일/폴더의 group 권한에 read/write/Execute 를 부여함.

$ chmod -R g+rwX .

하위 폴더의 권한에 s (이후 생성된 하위 폴더가 현재 폴더의 group 권한을 갖음) 을 부여함.

$ find . -type d -exec chmod g+s '{}' +


이상 git remote: error: insufficient permission for adding an object to repository database ./objects 발생시 수정 방법에 대한 글 이였습니다.






관련글 더보기