Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Create a bare repository in your git server
#!/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