Files
bin/git_repo.sh
rozbrian 304cbcc554 update
2026-01-10 20:46:22 +09:00

28 lines
599 B
Bash
Executable File

#!/bin/bash
# This script creates a bare Git repository under /home/git/
# Usage: ./create-git-repo.sh <project_name>
set -e
if [ -z "$1" ]; then
echo "Error: Project name is required."
echo "Usage: $0 <project_name>"
exit 1
fi
PROJECT_NAME=$1
REPO_PATH="/home/git/${PROJECT_NAME}.git"
# Create the directory
mkdir -p "$REPO_PATH"
# Initialize as bare repository
git init --bare "$REPO_PATH"
# Set ownership to user 'git'
chown -R git:git "$REPO_PATH"
echo "=== Repository created successfully ==="
echo "Path: $REPO_PATH"
echo "To clone: git clone git@your-server:${PROJECT_NAME}.git"