How to delete Git repository with Gitosis

I'm using Gitosis to administer some Git repositories on a remote server. Since I'm at the beginning with it, I make a lot of mistakes. That's why right now I need to delete a Git repository that I created with Gitosis. Is this possible using Gitosis or do I have to log into that machine and do it from there?


Solution 1:

Gitosis by itself does not have a remove function because of the way it is managed through git commits. If you remove the repository from the gitosis.conf and commit the change then the repository is no longer accessible. You can re-enable it later or you can eventually log into the server and remove the file from the gitosis repositories/ directory.

I cloned my gitosis-admin.git repository and added the following then committed:

[group gitosis-admin]
writable = gitosis-admin test1
members = jbouse

I then went to my home directory and performed the following:

mkdir test1
cd test1
git init
git remote add origin git@server:test1.git
echo "Testing" > test.txt
git add test.txt
git commit -m 'First commit'
git push origin master:refs/heads/master

This should successfully push to the server and then I wiped the test1 directory away and clone it from gitosis:

git clone git@server:test1.git
cd test1
echo "Test worked" > test.txt
git add test.txt
git commit -m 'Second commit'
git push

This should also push successfully as well so I then remove the test1 line from the gitosis.conf config and commit the change... I then try the following:

cd test1
echo "Final test" > test.txt
git add test.txt
git commit -m 'Third commit'
git push

Unlike the previous two pushes this one fails with the following error message:

ERROR:gitosis.serve.main:Repository read access denied
fatal: The remote end hung up unexpectedly

The error is because gitosis does not have anything configured for the test1 repository now. If you attempt to clone the repository again you will receive the same error.

Solution 2:

You have to log into the machine and remove the repository there and then you have also to remove the repository from the gitosis configuration file.