When working with Gitosis, repositories are typically stored in the /home/git/repositories/
directory on your server. Unlike standard Git, Gitosis adds an administrative layer where repositories are managed through configuration files rather than direct filesystem operations.
To safely remove a repository while maintaining Gitosis integrity:
# Step 1: Edit the Gitosis configuration
git clone git@yourserver.com:gitosis-admin.git
cd gitosis-admin
vim gitosis.conf
# Remove the repository section (example below)
[repo old-project]
description = Deprecated project
owner = john@example.com
After updating the config, you'll need to manually remove the repository files:
ssh git@yourserver.com
cd /home/git/repositories/
rm -rf old-project.git
Ensure the deletion was successful by attempting to clone the removed repository:
git clone git@yourserver.com:old-project.git
# Should return "fatal: 'old-project.git' does not appear to be a git repository"
Watch out for these frequent issues:
- Forgetting to push config changes back to gitosis-admin
- Permission errors when deleting repository files
- Dangling references in other projects' remotes
For scripted deletion, you can modify the config programmatically:
#!/bin/bash
REPO_NAME="obsolete-repo"
# Remove from config
sed -i "/\[repo $REPO_NAME\]/,/^$/d" gitosis.conf
# Push changes
git commit -am "Removed $REPO_NAME repository"
git push origin master
# Optional: Cleanup hook scripts
ssh git@yourserver.com "rm -f /home/git/repositories/$REPO_NAME.git/hooks/*"
When working with Gitosis, repositories are typically stored in the /home/git/repositories
directory on your server. The administration happens through a special Git repository that contains configuration files. To delete a repository properly, you need to modify both the configuration and the physical repository files.
First, clone the gitosis-admin repository to your local machine:
git clone git@your-server:gitosis-admin.git
cd gitosis-admin
Open gitosis.conf
in your favorite editor and remove the repository section. For example, if you want to delete a repository named "test-project", remove these lines:
[repo test-project]
description = Test Project
owner = your-email@example.com
After editing the configuration file:
git commit -am "Removed test-project repository"
git push origin master
SSH into your server and navigate to the repositories directory:
ssh your-server
cd /home/git/repositories
Remove the repository (including the .git directory):
rm -rf test-project.git
If you have gitosis-tools installed, you can use the gitosis-delrepo
command:
gitosis-delrepo test-project
- Always backup important repositories before deletion
- Ensure no active users are working with the repository
- Update any CI/CD pipelines that might reference the deleted repository
If you encounter permission errors when trying to delete the repository:
sudo chown -R git:git /home/git/repositories
sudo chmod -R 770 /home/git/repositories
For cases where the repository appears to be deleted but still shows in listings, try rebuilding the gitosis configuration:
sudo -u git gitosis-init < /home/git/.ssh/authorized_keys