So we are setup now thanks to Part 1.
Gitosis repository contents
If we issue the “find .” command locally inside the gitosis-admin directory we will see the following:
We have the .git folder, a gitosis.conf file, and a keydir with a pub key file.
Add our first project
Our project name for this example is lostechies. If you view the gitosis-admin.conf file you will see the initial content like so:
This is the result of the following command from the last part:
That command puts the public ssh key into the keydirs directory and adds the associated username from the file to be the first member of the gisotis-admin project. Hence seeing user@local as the member. It matches the filename of the pub file in the keydir directory (firstname.lastname@example.org). That’s how gitosis relates members listed in the conf file to the keys in the keydir directory, filename minus the pub extension.
Let’s edit this conf file to include our lostechies project:
It looks exactly like the gitosis-admin one. Now we commit it just like we would normally when using Git. We can add, then commit or commit with the -am argument. This is possible since the gitosis-admin.conf file is already tracked by the repository.
and push it to the remote gitosis-admin repository:
We need to create the lostechies repository locally, add an initial item (README in this case), and push it remotely. Gitosis won’t create the repository until something it pushed to it.
The lostechies repository now exists remotely. Currently my account is the only that has access. Let’s add another contributor.
Add our first contributors
Say I want to allow my friend Joe to have commit (writable) access to my lostechies repository and I want my friend Ryan to only have readonly access. I tell them to send me their public ssh keys. I make sure the files are named joe.pub and ryan.pub. I then put them into my local gitosis-admin repository’s keydir directory and then I edit the gitosis.conf file to be:
Notice that I had to create a whole new group (lostechies_ro) to setup Ryan’s readonly access. You can’t combine readonly and writable permissions in gitosis (wish we could – open source contribution there?).
Now I need to “git add” the new keys, and commit the changes to the conf file. Finally I push the changes.
Now Joe or Ryan can clone this repository:
NOTE: Again, if they receive the following error:
The solution, involving the .ssh/config file is in the first post in this series.
That is how you create a repository and add users.
If you are unable to connect you have the option of editing the gitosis.conf file with more message verbosity by adding “loglevel=DEBUG” at the top of the conf file:
This will give you more information on the ouput when trying to push to the remote repository.
Can’t push changes
As Scott Chacon states in his gitosis section of Pro Git:
“If you’ve lost push access by pushing a messed-up configuration, you can manually fix the file on the server under /home/git/.gitosis.conf — the file from which Gitosis reads its info. A push to the project takes the gitosis.conf file you just pushed up and sticks it there. If you edit that file manually, it remains like that until the next successful push to the gitosis-admin project.”
The .gitosis.conf file in the git user’s home directory is a symlink to the actual conf file in the gitosis-admin repository:
Next Part: Gitweb
Post Footer automatically generated by Add Post Footer Plugin for wordpress.