# Git 初始化并推送到 Gitee 脚本 # 使用方法:在 PowerShell 中执行 .\init-git.ps1 Write-Host "开始初始化 Git 仓库..." -ForegroundColor Green # 检查是否已初始化 if (Test-Path .git) { Write-Host "Git 仓库已存在,跳过初始化" -ForegroundColor Yellow } else { git init Write-Host "Git 仓库初始化完成" -ForegroundColor Green } # 添加所有文件 Write-Host "添加文件到暂存区..." -ForegroundColor Green git add . # 检查是否有未提交的更改 $status = git status --porcelain if ($status) { # 提交更改 Write-Host "提交更改..." -ForegroundColor Green git commit -m "chore: initial project setup" Write-Host "提交完成" -ForegroundColor Green } else { Write-Host "没有需要提交的更改" -ForegroundColor Yellow } # 检查远程仓库是否已配置 $remote = git remote get-url origin 2>$null if ($LASTEXITCODE -ne 0) { # 添加远程仓库 Write-Host "添加远程仓库..." -ForegroundColor Green git remote add origin git@gitee.com:liujingaiyuanjiao/svn-manager.git Write-Host "远程仓库已添加" -ForegroundColor Green } else { Write-Host "远程仓库已配置: $remote" -ForegroundColor Yellow } # 获取当前分支名 $branch = git branch --show-current if (-not $branch) { $branch = "master" git branch -M master } Write-Host "推送到 Gitee..." -ForegroundColor Green Write-Host "分支: $branch" -ForegroundColor Cyan git push -u origin $branch Write-Host "完成!" -ForegroundColor Green Write-Host "仓库地址: https://gitee.com/liujingaiyuanjiao/svn-manager" -ForegroundColor Cyan