#!/bin/bash # ===================================================== # 推送到 GitHub 脚本 # ===================================================== # 使用方法: # 1. 确保代理已启动 (http://127.0.0.1:7897) # 2. 确保已在 GitHub 创建私有仓库: xiaomoguhz/ProxyCLIP_TPAMI # 3. 运行: ./push_to_github.sh # ===================================================== set -e PROJECT_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )" cd "$PROJECT_ROOT" # 代理配置 PROXY="http://127.0.0.1:7897" # GitHub 仓库 REPO_URL="https://github.com/xiaomoguhz/ProxyCLIP_TPAMI.git" echo "==============================================" echo "📤 推送到 GitHub" echo "==============================================" echo "项目目录: $PROJECT_ROOT" echo "远程仓库: $REPO_URL" echo "代理: $PROXY" echo "" # 检查代理 echo "🔍 检查代理..." if curl -s --connect-timeout 5 -x "$PROXY" https://github.com > /dev/null 2>&1; then echo "✅ 代理可用" else echo "⚠️ 代理可能不可用,尝试直接连接..." PROXY="" fi # 配置 git 代理 if [ -n "$PROXY" ]; then git config http.proxy "$PROXY" git config https.proxy "$PROXY" echo "✅ 已配置 git 代理" else git config --unset http.proxy 2>/dev/null || true git config --unset https.proxy 2>/dev/null || true echo "⚠️ 未使用代理" fi # 检查远程仓库 if ! git remote | grep -q origin; then git remote add origin "$REPO_URL" echo "✅ 已添加远程仓库" else echo "✅ 远程仓库已配置" fi # 推送 echo "" echo "📤 推送中..." git push -u origin main echo "" echo "==============================================" echo "✅ 推送完成!" echo "==============================================" echo "仓库地址: $REPO_URL"