Add repository creation guide
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
102
CREATE_REPO_GUIDE.md
Normal file
102
CREATE_REPO_GUIDE.md
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
# 创建私有仓库并推送代码指南
|
||||||
|
|
||||||
|
## 步骤 1:在 Git 服务器上创建仓库
|
||||||
|
|
||||||
|
### 访问 Git 服务器
|
||||||
|
|
||||||
|
1. 打开浏览器,访问:**https://git.quanyu360.cn**
|
||||||
|
2. 使用以下凭据登录:
|
||||||
|
- **用户名**: `admin`
|
||||||
|
- **密码**: `ye972030`
|
||||||
|
|
||||||
|
### 创建新仓库
|
||||||
|
|
||||||
|
1. 登录后,点击 **"New Repository"** 或 **"新建仓库"** 按钮
|
||||||
|
2. 填写仓库信息:
|
||||||
|
- **仓库名称**: `wecom-ai-assistant`
|
||||||
|
- **命名空间/组织**: `admin`(如果可以选择)
|
||||||
|
- **可见性**: 选择 **Private(私有)**
|
||||||
|
- **初始化选项**:
|
||||||
|
- ❌ **不要**勾选 "Initialize repository with a README"
|
||||||
|
- ❌ **不要**勾选 "Add .gitignore"
|
||||||
|
- ❌ **不要**勾选 "Choose a license"
|
||||||
|
3. 点击 **"Create Repository"** 或 **"创建仓库"**
|
||||||
|
|
||||||
|
## 步骤 2:推送代码到私有仓库
|
||||||
|
|
||||||
|
创建仓库后,运行以下命令推送代码:
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
# 确保远程仓库已配置
|
||||||
|
git remote remove private 2>$null
|
||||||
|
git remote add private https://admin:ye972030@git.quanyu360.cn/admin/wecom-ai-assistant.git
|
||||||
|
|
||||||
|
# 推送代码
|
||||||
|
git push -u private main
|
||||||
|
```
|
||||||
|
|
||||||
|
## 一键脚本
|
||||||
|
|
||||||
|
如果仓库已创建,可以直接运行:
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
.\scripts\push-to-private-repo.ps1
|
||||||
|
```
|
||||||
|
|
||||||
|
## 验证
|
||||||
|
|
||||||
|
推送成功后,访问以下 URL 验证:
|
||||||
|
|
||||||
|
**仓库地址**: https://git.quanyu360.cn/admin/wecom-ai-assistant
|
||||||
|
|
||||||
|
## 故障排查
|
||||||
|
|
||||||
|
### 问题:推送时提示 "repository not found"
|
||||||
|
|
||||||
|
**原因**: 仓库尚未创建
|
||||||
|
|
||||||
|
**解决方案**:
|
||||||
|
1. 按照上面的步骤 1 手动创建仓库
|
||||||
|
2. 然后重新推送
|
||||||
|
|
||||||
|
### 问题:推送时提示认证失败
|
||||||
|
|
||||||
|
**解决方案**:
|
||||||
|
```powershell
|
||||||
|
# 更新远程 URL(包含凭据)
|
||||||
|
git remote set-url private https://admin:ye972030@git.quanyu360.cn/admin/wecom-ai-assistant.git
|
||||||
|
|
||||||
|
# 重新推送
|
||||||
|
git push -u private main
|
||||||
|
```
|
||||||
|
|
||||||
|
### 问题:仓库路径不正确
|
||||||
|
|
||||||
|
如果仓库路径不是 `/admin/wecom-ai-assistant`,请更新:
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
# 查看实际仓库 URL(在 Git 服务器上创建后可以看到)
|
||||||
|
# 然后更新远程 URL
|
||||||
|
git remote set-url private https://admin:ye972030@git.quanyu360.cn/实际路径/wecom-ai-assistant.git
|
||||||
|
```
|
||||||
|
|
||||||
|
## 完成后的配置
|
||||||
|
|
||||||
|
推送成功后,你的项目将有两个远程仓库:
|
||||||
|
|
||||||
|
- **origin**: GitHub 仓库(https://github.com/bujie9527/wecom-ai-assistant)
|
||||||
|
- **private**: 私有仓库(https://git.quanyu360.cn/admin/wecom-ai-assistant)
|
||||||
|
|
||||||
|
### 日常使用
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
# 推送到私有仓库(默认)
|
||||||
|
git push private main
|
||||||
|
|
||||||
|
# 推送到 GitHub
|
||||||
|
git push origin main
|
||||||
|
|
||||||
|
# 推送到两个仓库
|
||||||
|
git push private main
|
||||||
|
git push origin main
|
||||||
|
```
|
||||||
51
scripts/create-repo-api.ps1
Normal file
51
scripts/create-repo-api.ps1
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
# 使用 API 创建 Git 仓库
|
||||||
|
# 支持 Gitea 和 GitLab
|
||||||
|
|
||||||
|
$gitUrl = "https://git.quanyu360.cn"
|
||||||
|
$username = "admin"
|
||||||
|
$password = "ye972030"
|
||||||
|
$repoName = "wecom-ai-assistant"
|
||||||
|
$isPrivate = $true
|
||||||
|
|
||||||
|
Write-Host "=== 使用 API 创建 Git 仓库 ===" -ForegroundColor Cyan
|
||||||
|
Write-Host ""
|
||||||
|
|
||||||
|
# 尝试 Gitea API
|
||||||
|
Write-Host "尝试 Gitea API..." -ForegroundColor Yellow
|
||||||
|
$giteaApiUrl = "${gitUrl}/api/v1/user/repos"
|
||||||
|
$body = @{
|
||||||
|
name = $repoName
|
||||||
|
private = $isPrivate
|
||||||
|
} | ConvertTo-Json
|
||||||
|
|
||||||
|
$base64Auth = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("${username}:${password}"))
|
||||||
|
$headers = @{
|
||||||
|
"Authorization" = "Basic $base64Auth"
|
||||||
|
"Content-Type" = "application/json"
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$response = Invoke-RestMethod -Uri $giteaApiUrl -Method POST -Headers $headers -Body $body -ErrorAction Stop
|
||||||
|
Write-Host "✓ 仓库创建成功!" -ForegroundColor Green
|
||||||
|
Write-Host " 仓库 URL: $($response.clone_url)" -ForegroundColor Gray
|
||||||
|
Write-Host ""
|
||||||
|
|
||||||
|
# 配置远程仓库并推送
|
||||||
|
Write-Host "配置远程仓库..." -ForegroundColor Yellow
|
||||||
|
git remote remove private 2>$null
|
||||||
|
git remote add private "https://${username}:${password}@${gitUrl}/admin/${repoName}.git"
|
||||||
|
|
||||||
|
Write-Host "推送代码..." -ForegroundColor Yellow
|
||||||
|
git push -u private main
|
||||||
|
|
||||||
|
if ($LASTEXITCODE -eq 0) {
|
||||||
|
Write-Host "✓ 代码推送成功!" -ForegroundColor Green
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
Write-Host "✗ Gitea API 创建失败: $_" -ForegroundColor Red
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "请手动创建仓库:" -ForegroundColor Yellow
|
||||||
|
Write-Host "1. 访问: $gitUrl" -ForegroundColor Gray
|
||||||
|
Write-Host "2. 登录并创建新仓库: $repoName" -ForegroundColor Gray
|
||||||
|
Write-Host "3. 然后运行: git push -u private main" -ForegroundColor Gray
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user