私は既存のgitリポジトリ(裸のリポジトリ)を持っていますが、これまでは自分だけが書き込み可能でした。fooのすべてのメンバーがそれにプッシュできるように、それを一部のUNIXユーザーグループfooで開く必要があります。私は新しい gitリポジトリを簡単に設定できることを知っています:
git init --bare --shared=group repodir
chgrp -R foo repodir
しかし、私は既存のリポジトリディレクトリと同等の操作が必要です。
私は既存のgitリポジトリ(裸のリポジトリ)を持っていますが、これまでは自分だけが書き込み可能でした。fooのすべてのメンバーがそれにプッシュできるように、それを一部のUNIXユーザーグループfooで開く必要があります。私は新しい gitリポジトリを簡単に設定できることを知っています:
git init --bare --shared=group repodir
chgrp -R foo repodir
しかし、私は既存のリポジトリディレクトリと同等の操作が必要です。
回答:
これを試して、既存のリポジトリrepodirをグループ内のユーザーの作業に使用しますfoo。
chgrp -R foo repodir # set the group
chmod -R g+rw repodir # allow the group to read/write
chmod g+s `find repodir -type d` # new files get group id of directory
git init --bare --shared=all repodir # sets some important variables in repodir/config ("core.sharedRepository=2" and "receive.denyNonFastforwards=true")
git init --shared既存のリポジトリでコマンドを使用して、構成値を設定できます。またchmod、ファイルの権限を正しく取得するには、コマンドを実行する必要があります。
git pullではなくrootとしてなどを行ったために混乱している場合にも役立ちwww-data、結果として得られerror: insufficient permission for adding an object to repository database .git/objectsます。findand -type d/ を使用して間違っていたすべてのファイル/ディレクトリの所有権を修正したと思いましたtype -fが、この方法だけがエラーを取り除きました(一部のサブディレクトリのファイルがグループ書き込み可能ではなかったためでしょうか)
core.sharedRepositoryこれについて言及すると思います-ユーザーがすべてのファイルグループを書き込み可能にしないと、役に立たないようです。
repo dirで次のコマンドを実行します。
git config core.sharedRepository group
chgrp -R foo repodir
chmod -R g+w repodir
編集:頻繁な混乱に対処するために、これgroupは実際のキーワードですが、これをグループの名前で置き換えることは想定されていません。
groupグループの名前はどこですか:)
git config core.sharedRepository devから入力した後、git config私fatal: bad config value for 'core.sharedrepository' in .git/configはgit version 1.7.0.4(場合によってはその後のバージョンも)入力します
git config core.sharedRepository group groupグループの名前ではなく、実際の値です。
マージ@デビッドアンダーヒルと@kixorz答えを、私は私自身の(最終的な)ソリューションを作りました。
それはのためにある裸のレポと非裸のレポ。それらの間の違いはほとんどありませんが、このようにするとより明確になります。
ベアリポジトリ
cd <repo.git>/ # Enter inside the git repo
git config core.sharedRepository group # Update the git's config
chgrp -R <group-name> . # Change files and directories' group
chmod -R g+w . # Change permissions
chmod g-w objects/pack/* # Git pack files should be immutable
find -type d -exec chmod g+s {} + # New files get directory's group id
どこ:
<repo.git>は通常、サーバー(例:)上のベアリポジトリディレクトリmy_project.git/です。<group-name>gitユーザー(例:users)のグループ名です。非ベアリポジトリ
cd <project_dir>/ # Enter inside the project directory
git config core.sharedRepository group # Update the git's config
chgrp -R <group-name> . # Change files and directories' group
chmod -R g+w . # Change permissions
chmod g-w .git/objects/pack/* # Git pack files should be immutable
find -type d -exec chmod g+s {} + # New files get directory's group id
どこ:
<project_dir>.gitフォルダーを含むプロジェクトディレクトリです。<group-name>gitユーザー(例:users)のグループ名です。chmod g-w objects/pack/*(非ベアリポジトリの場合は、先頭に追加.git/)
find . -type d'でエラーが発生するunable to execute /bin/chmod: Argument list too long
chmod g+s `find . -type d`しません。使用find -type d -exec chmod g+s {} +
chmod g-w objects/*/*。このリポジトリでは空なので、infoサブディレクトリについてはわかりません。
これはおそらく必要ではありませんがgit init --bare --shared、denyNonFastForwardsオプションも設定することを指摘する価値があります。
git config receive.denyNonFastForwards true
このオプションの意味は次のとおりです。
receive.denyNonFastForwards既にプッシュしたコミットをリベースしてからもう一度プッシュしようとするか、リモートブランチが現在指しているコミットを含まないリモートブランチにコミットをプッシュしようとすると、拒否されます。これは一般的に良いポリシーです。ただし、リベースの場合は、自分が何をしているかがわかっていると判断し、プッシュコマンドに-fフラグを指定してリモートブランチを強制的に更新できます。
(http://git-scm.com/book/en/v2/Customizing-Git-Git-Configurationから)
グループに読み取り/書き込みを許可する上記の回答に加えて、ユーザーをグループに追加する必要もあります(「foo」など)。
sudo usermod -a -G [groupname] [username]
注:ユーザーが存在しない場合は、最初にユーザーを作成する必要があります