55 lines
2.0 KiB
PowerShell
55 lines
2.0 KiB
PowerShell
# 配置新的 Gitea 远程仓库
|
||
# 使用方法:修改下面的变量后运行此脚本
|
||
|
||
param(
|
||
[string]$GiteaUsername = "549727955", # 请修改为您的 Gitea 用户名
|
||
[string]$RepoName = "flnxi_sucai", # 请修改为您想要的仓库名
|
||
[string]$GiteaPassword = "wyj86758186",
|
||
[string]$GiteaUrl = "http://git.1080p.hk"
|
||
)
|
||
|
||
Write-Host "========================================" -ForegroundColor Cyan
|
||
Write-Host "配置新的 Gitea 远程仓库" -ForegroundColor Yellow
|
||
Write-Host "========================================" -ForegroundColor Cyan
|
||
Write-Host ""
|
||
|
||
# 检查是否已存在 my-origin 远程
|
||
$existingRemote = git remote get-url my-origin 2>$null
|
||
if ($existingRemote) {
|
||
Write-Host "⚠ 已存在 my-origin 远程仓库" -ForegroundColor Yellow
|
||
Write-Host "当前配置: $existingRemote" -ForegroundColor Gray
|
||
$confirm = Read-Host "是否要更新? (y/n)"
|
||
if ($confirm -ne "y") {
|
||
Write-Host "已取消" -ForegroundColor Red
|
||
exit 0
|
||
}
|
||
git remote remove my-origin
|
||
}
|
||
|
||
# 构建新的远程仓库 URL
|
||
$newRepoUrl = "$GiteaUrl/$GiteaUsername/$RepoName.git"
|
||
$newRepoUrlWithAuth = "$GiteaUrl/$GiteaUsername`:$GiteaPassword@$GiteaUsername/$RepoName.git"
|
||
|
||
Write-Host "添加新的远程仓库..." -ForegroundColor Yellow
|
||
Write-Host "仓库 URL: $newRepoUrl" -ForegroundColor Gray
|
||
Write-Host ""
|
||
|
||
# 添加新的远程仓库(命名为 my-origin,不影响原有的 origin)
|
||
git remote add my-origin $newRepoUrlWithAuth
|
||
|
||
if ($LASTEXITCODE -eq 0) {
|
||
Write-Host "✓ 成功添加远程仓库 'my-origin'" -ForegroundColor Green
|
||
Write-Host ""
|
||
Write-Host "当前远程仓库配置:" -ForegroundColor Cyan
|
||
git remote -v
|
||
Write-Host ""
|
||
Write-Host "下一步操作:" -ForegroundColor Yellow
|
||
Write-Host "1. 确保在 Gitea 上已创建仓库: $RepoName" -ForegroundColor White
|
||
Write-Host "2. 运行以下命令推送代码:" -ForegroundColor White
|
||
Write-Host " git push -u my-origin main" -ForegroundColor Green
|
||
} else {
|
||
Write-Host "✗ 添加远程仓库失败" -ForegroundColor Red
|
||
exit 1
|
||
}
|
||
|