Difference between revisions of "Gitolite"

From Fixme.ch
Jump to: navigation, search
(How to)
Line 4: Line 4:
 
* https://github.com/sitaramc/gitolite/wiki
 
* https://github.com/sitaramc/gitolite/wiki
  
== How to ==
+
== Usage ==
 +
* Access a repository like this:
 +
  git clone ssh://gitolite@git.fixme.ch:1337/$example
 +
* List repositories you can access
 +
  ssh gitolite@foo.fixme.ch -p 1337
 +
 
 +
== Administration ==
 
* Ask The following people to access the gitolite admin :
 
* Ask The following people to access the gitolite admin :
 
         RW    =  nemen
 
         RW    =  nemen
Line 14: Line 20:
 
         RW    =  prosouth
 
         RW    =  prosouth
 
         RW    =  artphi
 
         RW    =  artphi
 
+
=== Create a repo ===
== Usage ==
+
* Get the gitolite admin
* Gitolite admin: edit and push to this repository
+
 
   git clone ssh://gitolite@git.fixme.ch:1337/gitolite-admin
 
   git clone ssh://gitolite@git.fixme.ch:1337/gitolite-admin
Keep the file as clean as you left it.
+
* Edit conf/gitolite.conf, add your repo and permissions
* Access repository like this:
+
repo MySuperProject
  git clone ssh://gitolite@git.fixme.ch:1337/$example
+
    R = @all    #pull
* List repositories you can access
+
    RW = myuser  #push
  ssh gitolite@foo.fixme.ch -p 1337
+
    RW+ = myuser #rewrite history
 +
* Commit and push to foo
 +
git commit -am "Add XXX repo"
 +
git push origin master
 +
 
 +
=== Add user ===
 +
* Ask the user to create an ssh key and to give the public key
 +
ssh-keygen
 +
cat ~/.ssh/id_rsa.pub
 +
* Create a new file for the key in keydir
 +
echo 'ssh-rsa AAA[...]' > keydir/name@machine.pub
 +
git add keydir/name@machine.pub
 +
git commit -am "new key for name"
 +
git push origin master
  
 
== Tip ==
 
== Tip ==

Revision as of 11:36, 7 May 2013

Goal

Usage

  • Access a repository like this:
 git clone ssh://gitolite@git.fixme.ch:1337/$example
  • List repositories you can access
 ssh gitolite@foo.fixme.ch -p 1337

Administration

  • Ask The following people to access the gitolite admin :
       RW     =   nemen
       RW     =   malik
       RW     =   rorist
       RW     =   francois
       RW     =   anael
       RW     =   crazygolem
       RW     =   prosouth
       RW     =   artphi

Create a repo

  • Get the gitolite admin
 git clone ssh://gitolite@git.fixme.ch:1337/gitolite-admin
  • Edit conf/gitolite.conf, add your repo and permissions
repo MySuperProject
    R = @all     #pull
    RW = myuser  #push
    RW+ = myuser #rewrite history
  • Commit and push to foo
git commit -am "Add XXX repo"
git push origin master

Add user

  • Ask the user to create an ssh key and to give the public key
ssh-keygen
cat ~/.ssh/id_rsa.pub
  • Create a new file for the key in keydir
echo 'ssh-rsa AAA[...]' > keydir/name@machine.pub
git add keydir/name@machine.pub
git commit -am "new key for name"
git push origin master

Tip

If you don't want to specify the port every time you use ssh/git, you can add the host to your ~/.ssh/config:

 Host git.fixme.ch
     Port 1337

Deploy

  • There is a git hook to publish the application in prod
  • The deploy hook is located at /home/git/hooks/deploy.sh in the Internal_Server
  • You must add a post-receive hook in your project in a file /home/git/repositories/yourproject/hooks/post-receive with the following content:
DIR=/where/your/project/should/be/deployed #example: /var/www/foo/htdocs
APP=user-to-chown-to #example: www-data
/home/git/hooks/deploy.sh $APP $DIR

See also