2010-07-13 9 views
75

Ho un repository git esistente (uno nudo) che fino a questo punto è stato solo scrivibile da me. Voglio aprirlo ad un gruppo di utenti UNIX, foo, in modo che tutti i membri di foo possano inviarlo. Sono consapevole che posso facilmente impostare un nuovo repo git con:Come configurare un repository git esistente per essere condiviso da un gruppo UNIX

git init --bare --shared=group repodir 
chgrp -R foo repodir 

Ma ho bisogno l'operazione equivalente per un esistente dir pronti contro termine.

+2

C'è ** [una risposta eccellente a questa domanda] (http://serverfault.com/questions/26954/how -do-i-share-a-git-repository-with-multiple-users-on-a-machine) ** su ServerFault (un altro sito StackOverflow). – Zearin

risposta

88

Provate a fare un repository esistente in repodir lavoro per gli utenti nel gruppo 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") 
+13

Aggiungo che probabilmente dovresti anche impostare config.sharedRepository = true nella configurazione del repository. http://www.kernel.org/pub/software/scm/git/docs/git-config.html – Pistos

+0

Sì, buon punto. Grazie per aver segnalato che fuori Pistos! –

+1

Questo è abbastanza vicino a quello che stavo facendo da solo, ma volevo ottenere qualche conferma esterna. Grazie. :) Speravo anche che ci fosse un clone git --shared = genere di gruppo, ma l'opzione --shared di clone fa qualcosa di completamente diverso. – Pistos

34

Nel dir repo eseguire i seguenti comandi:

git config core.sharedRepository group 
chgrp -R foo repodir 
chmod -R g+w repodir 

Modifica: Per affrontare la confusione frequente, group è una parola chiave vera e propria, non devi sostituirla con il nome del gruppo.

+17

Dove 'group' NON è il nome del gruppo :) –

+0

g + w è un permesso errato ... !!! – Nizzy

+0

Perché il permesso è sbagliato? – kixorz

2

Questo probabilmente non è necessario, ma vale la pena sottolineare che git init --bare --shared imposta anche l'opzione denyNonFastForwards.

git config receive.denyNonFastForwards true 

Il significato di questa opzione è la seguente:

receive.denyNonFastForwards

If you rebase commits that you’ve already pushed and then try to push again, or otherwise try to push a commit to a remote branch that doesn’t contain the commit that the remote branch currently points to, you’ll be denied. This is generally good policy; but in the case of the rebase, you may determine that you know what you’re doing and can force-update the remote branch with a -f flag to your push command.

(da http://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration)

29

Unire @David Underhill e @kixorz risposte, ho fatto la mia soluzione (definitiva).

E 'per nude pronti contro termine e non nude pronti contro termine. Ci sono solo piccole differenze tra loro, ma in questo modo è più chiaro.

REPOSITORY NUDO

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 

dove:

  • <repo.git> è la directory di repository nuda, in genere sul server (ad esempio my_project.git/).
  • <group-name> è il nome del gruppo per utenti git (ad esempio utenti).

repository non-BARE

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 

dove:

  • <project_dir> è la directory del progetto che contiene la cartella .git.
  • <group-name> è il nome del gruppo per utenti git (ad esempio utenti).
+0

Come ha detto Charles, anche fare: 'chmod gw objects/pack/*' (se non-bare repository , anteporre '.git /') – Wernight

+0

@Wernight Ok, grazie, ho aggiornato anche la risposta – Andrea

+0

come possiamo trovare il nome del gruppo o come creare il nome del gruppo? – Sujithrao

0

In aggiunta alle risposte di cui sopra per consentire a un gruppo di leggere/scrivere è necessario aggiungere l'utente al gruppo (ad esempio "pippo").

sudo usermod -a -G [groupname] [username] 

Nota: si dovrà creare il primo utente, se non esiste

Problemi correlati