Thursday, June 23, 2011

gitolite - couldn't make it work with more than one person, switching to gitosis

I wanted github, but I need to keep my repository local, so I needed to roll my own. My last experiment with this used gitosis, but it looks like gitolite is a little more active now, and I hope has better documentation.

If you do something wrong and need to reinstal git.
https://github.com/sitaramc/gitolite/blob/pu/doc/1-INSTALL.mkd

uninstalling


cleaning out a botched install
When people have trouble installing gitolite, they often try to change a bunch of things manually on the server. This usually makes things worse ;-) so here's how to clean the slate.

client-side
edit ~/.ssh/config and delete the paragraph starting with host gitolite, if present.
remove ~/gitolite-admin
server-side
edit ~/.ssh/authorized_keys and delete all lines between # gitolite start and # gitolite end inclusive.
remove ~/.gitolite, ~/.gitolite.rc and ~/repositories/gitolite-admin.git

uninstalling gitolite completely
There's some duplication between this and the previous section, but uninstalling gitolite is described in great detail in doc/uninstall.mkd


I installed gitolite and then used bits from the following to configure and start using it.

Some References
upgrading to gitolite from gitosis

fix for error No refs in common and none specified doing nothing

I grabbed a copy of the admin repository

git clone ssh://git@SERVER:gitolite-admin


and I edited the file

gitolite-admin/conf/gitolite.conf

git status from within the gitolite-admin directory on my machine, showed the modifed file
git add .
git commit -m "added repo ericnotes"
git push

this modified the file, added the changes and committed them to the local git repo, then pushed them to my remote repository.


I added an ericnotes repository

repo gitolite-admin
RW+ = eabolden

repo testing
RW+ = @all

repo ericnotes
RW+ = eabolden


I then went to clone the new repository to give myself a local copy

git clone git@yourserveraddress:ericnotes


I them made some changes (added a file to the empty directory, git add ., then git commit -m "initial file commit" to save to local git repository

I then tried to push the file, and it failed, with a few different error messages.

the fix was to use the following.

git push --all



Repeat steps to practice again.

added the following to the gitolite.conf file
repo playarea
RW+ = eabolden

~/work $ cd gitolite-admin/
~/work/gitolite-admin(master) $ ls
conf keydir
~/work/gitolite-admin(master) $ git status
# On branch master
# Changes not staged for commit:
# (use "git add ..." to update what will be committed)
# (use "git checkout -- ..." to discard changes in working directory)
#
# modified: conf/gitolite.conf
#
no changes added to commit (use "git add" and/or "git commit -a")
~/work/gitolite-admin(master) $ git add .
~/work/gitolite-admin(master) $ git commit -m "added playarea repo"
[master 06adde2] added playarea repo
1 files changed, 3 insertions(+), 0 deletions(-)
~/work/gitolite-admin(master) $ git push
Warning: No xauth data; using fake authentication data for X11 forwarding.
Counting objects: 7, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (4/4), 369 bytes, done.
Total 4 (delta 1), reused 0 (delta 0)
remote: creating playarea...
remote: Initialized empty Git repository in /Users/git/repositories/playarea.git/
To git@yourserver:gitolite-admin
29e077c..06adde2 master -> master

$ git status
# On branch master
nothing to commit (working directory clean)

~/work $ git clone git@yourserver:playarea
Cloning into playarea...
Warning: No xauth data; using fake authentication data for X11 forwarding.
warning: You appear to have cloned an empty repository.
~/work $

$ touch testdoc.txt
~/work/playarea $ git add .
~/work/playarea $ git commit -m "initial commit"
[master (root-commit) 8a7328b] initial commit
0 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 testdoc.txt
~/work/playarea(master) $ git status
# On branch master
nothing to commit (working directory clean)
~/work/playarea(master) $ git push --all
Warning: No xauth data; using fake authentication data for X11 forwarding.
Counting objects: 3, done.
Writing objects: 100% (3/3), 214 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@yourserver:playarea
* [new branch] master -> master


Now things should be working as expected:


~/work/playarea(master) $ touch document2.txt
~/work/playarea(master) $ git add .
~/work/playarea(master) $ git commit -m "added second doc"
[master c8cf756] added second doc
0 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 document2.txt
~/work/playarea(master) $ git status
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
#
nothing to commit (working directory clean)
~/work/playarea(master) $ git push
Warning: No xauth data; using fake authentication data for X11 forwarding.
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 246 bytes, done.
Total 2 (delta 0), reused 0 (delta 0)
To git@yourserver:playarea
8a7328b..c8cf756 master -> master
javascript:void(0)