2012-10-07 52 views
8

我有git錯誤:每次創建「git push origin master」時都沒有足夠的權限將對象添加到存儲庫數據庫中。
我試過這裏描述的解決方案:http://parizek.com/2011/05/git-insufficient-permission-for-adding-an-object-to-repository-database-objects/,但它只能工作到下一次...
有沒有一些永久的解決方案?Git:沒有足夠的權限將對象添加到存儲庫數據庫

$ git push origin master 
Counting objects: 5, done. 
Delta compression using up to 2 threads. 
Compressing objects: 100% (3/3), done. 
Writing objects: 100% (3/3), 1.19 KiB, done. 
Total 3 (delta 2), reused 0 (delta 0) 
error: insufficient permission for adding an object to repository database ./objects 
fatal: failed to write object 
error: unpack failed: unpack-objects abnormal exit 
To ssh://[email protected]/p/project/code 
! [remote rejected] master -> master (n/a (unpacker error)) 
error: failed to push some refs to 'ssh://[email protected]/p/project/code' 

$ git config core.sharedRepository true 

$ git push origin master 
Counting objects: 5, done. 
Delta compression using up to 2 threads. 
Compressing objects: 100% (3/3), done. 
Writing objects: 100% (3/3), 1.19 KiB, done. 
Total 3 (delta 2), reused 0 (delta 0) 
error: insufficient permission for adding an object to repository database ./objects 
fatal: failed to write object 
error: unpack failed: unpack-objects abnormal exit 
To ssh://[email protected]/p/project/code 
! [remote rejected] master -> master (n/a (unpacker error)) 
error: failed to push some refs to 'ssh://[email protected]/p/project/code' 

$ sudo chmod -R g+ws * 
$ sudo chgrp -R andrey * 
$ git push origin master 
Counting objects: 5, done. 
Delta compression using up to 2 threads. 
Compressing objects: 100% (3/3), done. 
Writing objects: 100% (3/3), 1.19 KiB, done. 
Total 3 (delta 2), reused 0 (delta 0) 
remote: <Repository /git/p/project/code.git> refresh queued. 
To ssh://[email protected]/p/project/code 
    acd82d2..f401c90 master -> master 

這是Ubuntu的使用:12.04.1,和git:1.7.9.5

+1

你爲什麼要這樣做?使用github或gitorious或已經解決了這個問題的解決方案。 –

+1

如果我在source forge中存儲代碼,可以使用這些工具嗎? – rodnower

+2

@Stefan Kendall:也許用戶使用的是公司內部的Git項目,他或他的公司不想將他們的代碼移動到他們無法控制的外部服務上? –

回答

4

正如在 「Error pushing to GitHub - insufficient permission for adding an object to repository database」 提到的,你需要的,除了git的配置設置,以:

  • 首先爲所有的回購協議umaskumask 002(讓你的服務器端)
  • 然後設置混帳組rw作爲服務器端解決方案中的提到的,仍。
+0

好吧,它似乎工作。我也把umask命令放在.bashrc文件中。 – rodnower

+0

那個'umask 002/var/git/repositories'是做什麼的? 'umask' shell內置函數不能以這種方式工作。 – wRAR

+0

@wRAR爲true,我刪除了該命令中的目錄。 – VonC

0

這種情況通常發生在有人在噓根時承諾進行git操作。 在該進程中創建的.git/*文件受到外部更改的保護。

chmod -R 777 .git 

是一個快速修復程序。

相關問題