Created
June 17, 2011 12:45
-
-
Save gorenje/1031349 to your computer and use it in GitHub Desktop.
gitosis-init alias for creating new gitosis git repos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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