Files
hr-performance-system/docs/GITEA_SETUP.md
2025-12-03 23:42:15 +08:00

154 lines
3.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Gitea Repository 設定指南
## 連線資訊
- **Gitea URL**: https://gitea.theaken.com/
- **使用者**: donald
- **Token**: 9e0a888d1a25bde9cf2ad5dff2bb7ee6d68d6ff0
## 設定步驟
### 1. 在 Gitea 上建立 Repository
由於系統不允許透過 push 自動建立 repository需要先在 Gitea 上手動建立:
1. 登入 Gitea: https://gitea.theaken.com/
2. 點擊右上角的 "+" 按鈕
3. 選擇 "新建倉庫" (New Repository)
4. 填寫以下資訊:
- **倉庫名稱**: `hr-performance-system`
- **可見性**: 私有 (Private) 或 公開 (Public)
- **描述**: HR 績效評核系統 - 四卡循環管理平台
- **不要**勾選 "使用 README 初始化"
5. 點擊 "建立倉庫"
### 2. 推送本地代碼
Repository 建立完成後,在本地執行:
```bash
# 確認遠端設定
git remote -v
# 如果還沒設定遠端,執行:
git remote add origin https://gitea.theaken.com/donald/hr-performance-system.git
# 使用 token 推送(推薦)
git push -u https://donald:9e0a888d1a25bde9cf2ad5dff2bb7ee6d68d6ff0@gitea.theaken.com/donald/hr-performance-system.git master
# 或設定 credential helper 後推送
git config credential.helper store
git push -u origin master
# 輸入使用者名稱: donald
# 輸入密碼: 9e0a888d1a25bde9cf2ad5dff2bb7ee6d68d6ff0
```
### 3. 設定 Git Credential (可選)
為了避免每次都要輸入密碼,可以設定 credential helper
**Windows:**
```bash
git config --global credential.helper wincred
```
**Linux/Mac:**
```bash
git config --global credential.helper store
```
### 4. 使用 Token 進行認證
在需要輸入密碼時,使用 token 代替密碼:
- **使用者名稱**: donald
- **密碼**: 9e0a888d1a25bde9cf2ad5dff2bb7ee6d68d6ff0 (使用 token)
或在 URL 中直接包含 token
```bash
git clone https://donald:9e0a888d1a25bde9cf2ad5dff2bb7ee6d68d6ff0@gitea.theaken.com/donald/hr-performance-system.git
```
## 常用 Git 指令
### 查看狀態
```bash
git status
```
### 拉取最新代碼
```bash
git pull origin master
```
### 提交變更
```bash
git add .
git commit -m "提交訊息"
git push origin master
```
### 查看提交歷史
```bash
git log --oneline
```
### 建立分支
```bash
git checkout -b feature/new-feature
git push -u origin feature/new-feature
```
## 疑難排解
### 錯誤: Push to create is not enabled
**原因**: Gitea 設定不允許透過 push 自動建立 repository
**解決方案**: 先在 Gitea 網頁介面手動建立 repository
### 錯誤: 403 Forbidden
**原因**: 認證失敗或權限不足
**解決方案**:
1. 確認 token 是否正確
2. 確認使用者有推送權限
3. 確認 repository 已存在
### 錯誤: remote: Repository does not exist
**原因**: Repository 尚未建立
**解決方案**: 在 Gitea 上先建立 repository
## Repository 資訊
建立完成後Repository 資訊如下:
- **URL**: https://gitea.theaken.com/donald/hr-performance-system
- **Clone URL (HTTPS)**: https://gitea.theaken.com/donald/hr-performance-system.git
- **Clone URL (SSH)**: git@gitea.theaken.com:donald/hr-performance-system.git
## 安全提醒
⚠️ **重要**: Token 具有完整的帳號權限,請妥善保管!
- 不要將 token 提交到公開的 repository
- 不要在程式碼中硬編碼 token
- 定期更換 token
- 如果 token 外洩,請立即在 Gitea 設定中撤銷
## 下一步
1. ✅ 初始化 Git repository
2. ✅ 建立初始 commit
3. ⏳ 在 Gitea 上建立 repository
4. ⏳ 推送代碼到 Gitea
5. ⏳ 設定專案的 README 和描述
---
**建立日期**: 2025-12-03