#!/usr/bin/env bash # ============================================================ # git-repo-create@tx-ubuntu-git.sh # 在 git 用户下创建裸仓库(bare repo),作为本地 git push 的目标 # # 用法: claw run tx-ubuntu-git git-repo-create@tx-ubuntu-git.sh # 适用: Ubuntu 24.04 # # 前置条件: # - git 用户已创建,SSH 密钥已配置 # - /home/git/repos 目录可写 # # 路径约定: # - 裸仓库: /home/git/repos/<项目名>.git # - 通过 SSH git@62.234.90.54 访问 # # 如需新增其他项目,复制此脚本,修改 REPO 变量即可 # ============================================================ set -e # ---- 配置(新增项目改这里) ---- BASEDIR="/home/git/repos" # 裸仓库根目录 REPO="Work" # 项目名 # ------------------------------- REPO_PATH="$BASEDIR/$REPO.git" if [ -d "$REPO_PATH" ]; then echo "仓库已存在: $REPO_PATH" else mkdir -p "$BASEDIR" git init --bare "$REPO_PATH" echo "仓库创建完成: $REPO_PATH" fi echo "" echo "=== 本地使用 ===" echo " git remote add tx ssh://git@62.234.90.54$REPO_PATH" echo " git push -u tx main"