Created
July 22, 2014 21:20
-
-
Save jbouzekri/35481a7c087bac61758c to your computer and use it in GitHub Desktop.
Create a bare repository in your git server
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 | |
: ' | |
Place this script in a folder of your PATH and add execute rights to it | |
You can then use git create-repo REPO_NAME (without .git at the end) to init a bare repo in your current folder | |
' | |
set -e | |
if [ $# -ne 1 ] | |
then | |
echo "Usage: git create-repo REPO_NAME" | |
exit 1 | |
fi | |
SCRIPTPATH=`pwd -P` | |
GIT_FOLDER=$1.git | |
mkdir $GIT_FOLDER | |
echo "Empty folder created to $SCRIPTPATH/$GIT_FOLDER/" | |
cd $GIT_FOLDER | |
git --bare init | |
mv hooks/post-update.sample hooks/post-update | |
read -e -p "What is the description of your git repo ? " GIT_DESCRIPTION | |
if [ ! -z "$GIT_DESCRIPTION" ] | |
then | |
echo "$GIT_DESCRIPTION" > description | |
echo "Repo description updated" | |
fi | |
read -e -p "What is the owner of your git repo ? " -i "git" GIT_USER | |
chown $GIT_USER:$GIT_USER . -R | |
echo "Repo user and group chown to $GIT_USER" | |
chmod 755 . -R | |
echo "Repo rights changed to 755" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment