Created
August 18, 2011 09:36
-
-
Save alexrinass/1153746 to your computer and use it in GitHub Desktop.
Creates a new Git repository on Debian/Ubuntu Linux
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/sh | |
# | |
# Script to create an empty Git-Repository. | |
# | |
GIT_BASEPATH=/var/cache/git | |
SCRIPT_NAME="`basename $0`" | |
PROJECT_NAME="$1" | |
if [ -z "$PROJECT_NAME" ]; then | |
echo "Usage: $SCRIPT_NAME PROJECT_NAME" | |
exit 0 | |
fi | |
PROJECT_NAME="`basename $PROJECT_NAME .git`.git" | |
PROJECT_PATH="$GIT_BASEPATH/$PROJECT_NAME" | |
if [ -d "$PROJECT_PATH" ]; then | |
echo "An Git repository already exists at $PROJECT_PATH! Aborting." | |
exit 0 | |
fi | |
if [ ! -w "$GIT_BASEPATH" ]; then | |
echo "The directory $GIT_BASEBATH is not writeable for your user. Maybe you forgot sudo? Aborting." | |
exit 0 | |
fi | |
echo "Creating directory at $PROJECT_PATH..." | |
mkdir $PROJECT_PATH | |
chmod 2775 $PROJECT_PATH | |
echo "Initializing empty Git repository..." | |
cd $PROJECT_PATH | |
git --bare init --shared=group | |
#echo "Changing group to git..." | |
chown -R :git $PROJECT_PATH | |
#echo "Ensure group write permissions (g+w)..." | |
#chmod -R g+w $PROJECT_PATH | |
echo "Done." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment