git實戰4 – 遇到錯誤時


下達指令

git push origin store:store

出現以下權限錯誤

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

fatal: failed to write object
error: unpack failed: unpack-objects abnormal exit
To git@192.168.1.100:/home/git/project/lywtp/.git
! [remote rejected] store -> store (n/a (unpacker error))
error: failed to push some refs to 'git@192.168.1.100:/home/git/project/lywtp/.git'

注意:
有時候會忘記我們是用 root 身份登入操作,並建立 git 倉庫和建立忽略名單 .gitignore
要修改成適合的擁有者 ( git:git )
才能建立新的分支

drwxr-xr-x  8 root root    4096 2014-06-30 08:12 .git/
-rw-r--r--  1 root root      35 2014-06-30 07:53 .gitignore

修改成

drwxr-xr-x  8 git git    4096 2014-06-30 08:12 .git/
-rw-r--r--  1 git git      35 2014-06-30 07:53 .gitignore

這樣就可以

git push origin store:store
git@192.168.1.100's password:
Counting objects: 4, done.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 305 bytes, done.
Total 3 (delta 1), reused 0 (delta 0)
To git@192.168.1.100:/home/git/project/lywtp/.git
* [new branch]      store -> store