Skip to content

Instantly share code, notes, and snippets.

@gorenje
Created June 17, 2011 12:45
Show Gist options
  • Save gorenje/1031349 to your computer and use it in GitHub Desktop.
Save gorenje/1031349 to your computer and use it in GitHub Desktop.
gitosis-init alias for creating new gitosis git repos
function _funct_gitosis_init {
## create a new remote repo once the gitosis conf has been updated
while getopts "h" option
do
case $option in
h)
echo "For example: gitosis-init [email protected]:username.git"
return
;;
esac
done
local repourl=$1
local reponame=${repourl/*:/}
reponame=${reponame/.git}
if [ -d $reponame ] ; then
echo "directory ${reponame} already exists, exiting ..."
return
fi
currdir=`pwd`
mkdir $reponame
cd $reponame
git init
git remote add origin ${repourl}
touch .keep
git add .keep
git commit -a -m "initial commit"
git push origin master:refs/heads/master
cd $currdir
rm -fr ${reponame}
git clone ${repourl}
}
alias gitosis-init=_funct_gitosis_init
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment