gitosis-create-repo
Posted on in Development, Server
A simple script to create a new gitosis-repository on the fly. I’m not really familiar with bash scripting so don’t expect too much ;)
#!/bin/bash
if [ -z $1 ]; then
echo "Please specify a repository."
exit 1
fi
if [ -z $2 ]; then
echo "Please specify a remote url."
exit 1
fi
if [ -d $1 ]; then
echo "Repository already exists."
exit 1
fi
mkdir $1
cd $1
git init
touch .gitignore
git add .gitignore
git commit -a -m "Initial commit."
git remote add origin $2:$1.git
git push origin master:refs/heads/master
Please make sure you set the correct permissions in gitosis.conf. Example:
[group me] members = me@example.com writable = test
Then you can run the script to create a new repository test on myhost.example.org:
$ gitosis-create-repo test git@myhost.example.org