Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@tvrcgo
Last active December 15, 2015 10:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tvrcgo/972d610338ee8c58f7ec to your computer and use it in GitHub Desktop.
Save tvrcgo/972d610338ee8c58f7ec to your computer and use it in GitHub Desktop.
git repository initialization
#!/bin/bash
REPO_ROOT=/home/git/node
cd ${REPO_ROOT}
if [ -z "$1" ]; then
echo "------ fail: repository name required. ------"
exit 0
fi
if [ "$1" = "rm" ] && [ -n "$2" ]
then
mv "$2" .recycle/
echo "------ Project <$2> Recycled. ------"
exit 0
fi
if [ "$1" = "cls" ] && [ -z "$2" ]
then
rm .recycle/* -rf
echo "------ Recycled Empty ------"
exit 0
fi
if [ "$1" = "ll" ] && [ -z "$2" ]; then
ls ${REPO_ROOT}
exit 0
fi
echo "------ Init Project ------"
git init $1
cd $1
git config --add receive.denyCurrentBranch ignore
echo "### $1" > README.md
echo -e ".DS_Store\n/node_module\n*.log" > .gitignore
git add -A
git commit -am "Initial commit."
git branch dev
chown git:git . -R
if [ -n "$2" ] && [ "$2" = "--bare" ]
then
cd hooks
else
cd .git/hooks
fi
if [ -e "post-receive.sample" ]; then
mv post-receive.sample post-receive
fi
echo "------ Project <$1> Init Complete! ------"
echo "git clone git@example.com:${REPO_ROOT}/$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment