update
This commit is contained in:
27
git_repo.sh
Executable file
27
git_repo.sh
Executable file
@@ -0,0 +1,27 @@
|
||||
#!/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"
|
||||
Reference in New Issue
Block a user