-
-
Save tvrcgo/972d610338ee8c58f7ec to your computer and use it in GitHub Desktop.
git repository initialization
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
#!/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