我有一個git倉庫,它具有dev,test和staging分支,這些分支被拉到服務器上的虛擬主機上。我需要能夠使用我的用戶帳戶來拉扯服務器,但是拉扯爲由www-data用戶(和組)擁有的文件。當我使用svn時,我可以sudo作爲www-data和svn更新--username --password選項,它將針對svn進行身份驗證,但保持正確的文件所有權。有沒有辦法用git來做到這一點(我實際上使用SSH密鑰而不是密碼進行身份驗證)。Git pull wih www-data permissions
回答
你想設置存儲庫這個選項你拉進(摘自git help config
):
core.sharedRepository
When group (or true), the repository is made shareable between several
users in a group (making sure all the files and objects are
group-writable). When all (or world or everybody), the repository will
be readable by all users, additionally to being group-shareable. When
umask (or false), git will use permissions reported by umask(2). When
0xxx, where 0xxx is an octal number, files in the repository will have
this mode value. 0xxx will override user’s umask value (whereas the
other options will only override requested parts of the user’s umask
value). Examples: 0660 will make the repo read/write-able for the
owner and group, but inaccessible to others (equivalent to group
unless umask is e.g. 0022). 0640 is a repository that is
group-readable but not group-writable. See git-init(1). False by
default.
要設置這個選項,cd
到需要有正確的組工作樹或庫/模式(而不是您想要從中取得的原始存儲庫),並運行git config core.sharedRepository group
。它不僅爲存儲庫中的文件設置模式,還確保它們全部由擁有存儲庫根目錄的組擁有。無論您在存儲庫本地工作還是從其他存儲庫推入(例如通過git://
協議),該選項都會生效。
如果您已經使用了錯誤的所有者和/或模式下沒有此選項集創建倉庫裏的文件,你需要先cd
到庫中,並運行chmod -R g+rw .
和chgrp -R www-data .
把它變成一個一致州。
感謝您的回答。我這樣做的主要問題是我不能訪問git存儲庫本身,因爲它位於第三方基礎架構上。我正在考慮將這一切都轉移到GitHub上,但我不知道這是否會讓我的生活更輕鬆。 – 2013-04-26 10:24:44
不要忘記,在Git中,每個工作副本都有自己的存儲庫:*存儲庫*並不意味着*上游*。您只需要存儲庫上的此設置即可擁有合適的組/模式。你**不需要做任何事情來源於你的原始資源庫。 – 2013-04-26 10:30:10
- 1. Git post-receive permissions
- 2. Git Hook for git pull
- 3. git pull VS git fetch git rebase
- 4. git tf pull在
- 5. MATLAB git Pull
- 6. Git Pull Aborting
- 7. shell_exec和git pull
- 8. Git pull remote repo
- 9. git windows post pull
- 10. phpstorm git pull --rebase
- 11. git pull errors
- 12. git rebase after pull
- 13. Git pull change log
- 14. 配置git讓「git pull」代替「git pull origin master」?
- 15. 撤消git存儲,git pull
- 16. 無法'git submodule foreach git pull'
- 17. 瞭解git pull和git fetch
- 18. git fetch和git pull混淆
- 19. git java wrapper - git pull never ends
- 20. git pull terminal allow everyone
- 21. xcode git pull/push crash
- 22. git merge,push,pull confusion
- 23. git submodule commit/push/pull
- 24. Git force pull remote from
- 25. 撤銷git pull --rebase?
- 26. 我可以使用git pull --rebase而不是「git stash git pull git stash pop」嗎?
- 27. 如何設置`git pull`來做`git pull origin master`呢?
- 28. 爲什麼git pull origin master不能工作,但是git pull呢?
- 29. 如何調試:git pull在git pull期間掛起(allways爲54%)
- 30. 「git pull origin」和「git pull remote」有什麼區別?
其實,在重新閱讀你的問題時,我不清楚。 *哪個*文件需要由該用戶和組擁有?版本控制下的'真正'文件,'.git'目錄下的Git文件,還是兩者都有?如果您試圖從Git存儲庫提供網站,則只需要「真實」文件即可擁有該用戶;如果您試圖共享存儲庫,或者允許通過HTTP訪問存儲庫,則需要Git的文件才能擁有該用戶。 – 2013-04-26 10:38:47