As you get more into git, you might want to host your own git repositories. A great way to do that is to use Gitosis. There are some great tutorials on how to install and set it up out there already so I won’t go into that.
When setup and ready the following script might save you a couple of minutes when adding a git repository to your gitosis setup.
#!/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
Make sure you save this into a file, make it executable as usual with ´chmod 755 file´ and push your ´gitosis.conf´ with some changes:
[group mygroup]
members = me@computer.local
writable = testrepository
Then you can use the script as follow:
$ gitosis-create-repo testrepository git@gitserver.remote