summaryrefslogtreecommitdiff
path: root/init-repo
diff options
context:
space:
mode:
authorElizabeth Hunt <me@liz.coffee>2025-12-05 21:43:18 -0800
committerElizabeth Hunt <me@liz.coffee>2025-12-05 22:19:52 -0800
commit8667f8615da479a8e9c4e8d5bb5987632d75bfaf (patch)
treee3b4bdb4ebe4f0010c90dd43970822bbe8f8d4a6 /init-repo
parent4cde5dedcf35f2d5850ce0479f25d29bac74daf7 (diff)
downloadwwwgit-8667f8615da479a8e9c4e8d5bb5987632d75bfaf.tar.gz
wwwgit-8667f8615da479a8e9c4e8d5bb5987632d75bfaf.zip
Add ssh server
Diffstat (limited to 'init-repo')
-rw-r--r--init-repo38
1 files changed, 38 insertions, 0 deletions
diff --git a/init-repo b/init-repo
new file mode 100644
index 0000000..5749866
--- /dev/null
+++ b/init-repo
@@ -0,0 +1,38 @@
+#!/bin/sh
+# Helper script for git-shell to initialize bare repositories
+# Usage: ssh code@host init-repo <repo-name> [description]
+
+if [ $# -lt 1 ] || [ $# -gt 2 ]; then
+ echo "Usage: init-repo <repo-name> [description]"
+ echo "Example: init-repo myproject.git"
+ echo "Example: init-repo myproject.git 'A repo with foo'"
+ exit 1
+fi
+
+REPO_NAME="$1"
+DESCRIPTION="$2"
+
+# Ensure it ends with .git
+case "$REPO_NAME" in
+ *.git) ;;
+ *) REPO_NAME="${REPO_NAME}.git" ;;
+esac
+
+REPO_DIR="$HOME/$REPO_NAME"
+
+if [ -e "$REPO_DIR" ]; then
+ echo "Error: Repository '$REPO_NAME' already exists"
+ exit 1
+fi
+
+echo "Initializing bare repository: $REPO_NAME"
+git init --bare "$REPO_DIR"
+
+# Add description if provided
+if [ -n "$DESCRIPTION" ]; then
+ echo "$DESCRIPTION" > "$REPO_DIR/description"
+ echo "Description set: $DESCRIPTION"
+fi
+
+echo "Repository initialized at: $REPO_DIR"
+echo "You can now push to it with: git remote add origin ssh://code@host/$REPO_NAME"