# ================= 配置区 =================
$ServerA_User = "dxw"
$ServerA_IP = "222.20.97.222"
$RemotePath = "/public/home/dxw/Codes/afem"  # 服务器A上项目的绝对路径
$LocalPath = "F:\ASMRplusplus-main"             # 本地项目路径
# ==========================================

Write-Host ">>> Step 1: Downloading code from Server A..." -ForegroundColor Cyan
scp -r "${ServerA_User}@${ServerA_IP}:${RemotePath}/*" $LocalPath

Write-Host ">>> Step 2: Preparing to commit to Git..." -ForegroundColor Cyan
Set-Location $LocalPath
git add .

$date = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
git commit -m "Auto-sync from Server A at $date"

Write-Host ">>> Step 3: Pushing to Git Server B..." -ForegroundColor Cyan
git push origin main

Write-Host "`n[Success] All operations completed!" -ForegroundColor Green
Pause