Search This Blog

Tuesday, July 10, 2012

adding and removing repos

adding and removing repos:

adding and removing repos

NOTE: this page describes how to add new repos. To bring already existing repos into gitolite control, click here.

WARNING: Do NOT add new repos or users manually on the server. Gitolite users, repos, and access rules are maintained by making changes to a special repo called 'gitolite-admin' and pushing those changes to the server.

Just as for users, all operations are in a clone of the gitolite-admin repo.
To add a new repo, edit conf/gitolite.conf and add it, along with at least one user with some permissions. Or add it to an existing repo line:
repo gitolite tsh gitpod
    RW+     =   sitaram
    RW  dev =   alice bob
    R       =   @all
The "repo" line can have any number of repo names or repo group names in it. However, it can only be one line; this will not work
repo foo
repo bar    # WRONG; 'foo' is now forgotten
    RW      =   alice
If you have too many, use a group name:
@myrepos    =   foo
@myrepos    =   bar

repo @myrepos
    RW      =   alice
Finally, you add, commit, and push this change. Gitolite will create a bare, empty, repo on the server that is ready to be cloned.
Removing a repo is not so straightforward. You certainly must remove the appropriate lines from the conf/gitolite.conffile, but gitolite will not automatically delete the repo from the server. You have to log on to the server and do the dirty deed yourself :-)
It is best to make the change in the conf file, push it, and then go to the server and do what you need to.
Renaming a repo is also not automatic. Here's what you do (and the order is important):
  • Go to the server and rename the repo at the Unix command line.
  • Change the name in the conf/gitolite.conf file and add/commit/push.

rare or one-time activities

rare or one-time activities:

moving existing repos into gitolite

On the server:
  • Move the repos to $HOME/repositories.
  • Make sure that:
    • They are all bare repos.
    • All the repo names end in ".git".
    • All the files and directories are owned and writable by the gitolite hosting user (especially true if you copied them as root).
  • Run gitolite setupIf you forget this step, you can also forget about write access control!
Back on your workstation:
  • Add them to conf/gitolite.conf in your clone of the admin repo, then commit and push the change.
    If the repos are already covered by some wild pattern, this is optional.

Ubuntu 12.04 – Installing Gitolite and Gitweb - countableSet

Ubuntu 12.04 – Installing Gitolite and Gitweb - countableSet:

Note this is only tested on Ubuntu 12.04 Server with apache2, I’m sure it would work on the desktop version also.

Installing Git:

sudo apt-get install git-core
Optional, setup git global settings:
git config --global "Your Name"
git config --global

SSH Key:

Generate ssh public/private key on the machine you would like to access git repo from and copy it to the server into the /tmp/ directory, for reference here is the command:
ssh-keygen -t rsa -C "name@computer"

Installing Gitolite:

sudo apt-get install gitolite
Create a user to access gitolite with, in this case I chose git since I don’t like to type:
sudo adduser \
    --system \
    --shell /bin/bash \
    --gecos 'git version control' \
    --group \
    --disabled-password \
    --home /home/git \
Now login to the newly created user, and set the path, and move to its home directory:
sudo su git
echo "PATH=$HOME/bin:$PATH" > ~/.bashrc
Run the gitolite setup command with the public key you copied to the tmp directory to initialized the location for gitolite use. Then change the $REPO_UMASK to 0027 when it opens the .gitolite.rc for editing during the installation process. If it didn’t open the file for any reason just open it up in vim (Note this is only if you’d like to use gitweb):
gl-setup /tmp/
# change $REPO_UMASK = 0077; to $REPO_UMASK = 0027; # gets you 'rwxr-x---'
Afterward, it has made the gitolite-admin.git, testing.git repo and all other necessary files. Check to see that everything works by cloning the repo on the machine with the public/private key.
git clone git@<server>:gitolite-admin.git
Here is a resource about the syntax for the config file and adding users.

Install Gitweb:

This is the tricky bit… Install gitweb and the highlight app. Gitweb is located at ‘/usr/share/gitweb’
sudo apt-get install highlight gitweb
Edit the gitweb config to the locations of the project list and repos, and add the highlighting bit at the end of the file:
sudo vim /etc/gitweb.conf
# change $projectroot to /home/git/repositories
# change $projects_list to /home/git/projects.list
# Add Highlighting at the end
$feature{'highlight'}{'default'} = [1];
Change gitolite instance to allow access for gitweb. First append www-data to git group so gitweb can access the repos, then change the permissions for git repos and the projects list, finally restart apache:
sudo usermod -a -G git www-data
sudo chmod g+r /home/git/projects.list
sudo chmod -R g+rx /home/git/repositories
sudo service apache2 restart
Finally you need to tell gitolite which repo you want to show up in gitweb. To do this edit the gitolite.conf file from the gitolite-admin.git repo:
repo testing
  RW+ = @all
  R = gitweb