-
前往倉庫設置
- 打開你的 GitHub 倉庫頁面
- 點擊
Settings(設置)標籤
-
添加協作者
- 在左側菜單中選擇
Collaborators(協作者)或Collaborators and teams - 點擊
Add people(添加人員)按鈕 - 輸入
manus-agent的 GitHub 用戶名或電子郵件 - 選擇適當的權限級別:
Read: 只讀訪問Write: 可以推送到倉庫Admin: 完全管理權限
- 在左側菜單中選擇
-
發送邀請
- 點擊
Add [username] to this repository - manus-agent 將收到邀請通知
- 點擊
如果你的倉庫屬於一個組織:
- 前往組織的
Teams頁面 - 創建一個新團隊或選擇現有團隊
- 將 manus-agent 添加到團隊
- 為該團隊分配倉庫訪問權限
GitHub Personal Access Token 允許 AI 代理(如 manus-agent)以編程方式訪問你的倉庫。
- 登錄你的 GitHub 帳戶
- 點擊右上角的頭像,選擇
Settings - 在左側菜單底部,選擇
Developer settings - 選擇
Personal access tokens→Tokens (classic)或Fine-grained tokens
使用 Fine-grained tokens(推薦):
- 點擊
Generate new token→Generate new token (fine-grained) - 填寫 Token 詳情:
- Token name: 例如 "manus-agent-access"
- Expiration: 選擇過期時間(建議:90天或自定義)
- Description: 例如 "Token for manus-agent to access repository"
- Repository access: 選擇 "Only select repositories",然後選擇此倉庫
- 設置權限(Permissions):
- Repository permissions:
Contents: Read and write(讀寫代碼)Issues: Read and write(管理 Issues)Pull requests: Read and write(管理 PR)Metadata: Read-only(自動包含)Workflows: Read and write(如果需要修改 Actions)
- Repository permissions:
- 點擊
Generate token
使用 Classic tokens:
- 點擊
Generate new token→Generate new token (classic) - 填寫 Note(備註):例如 "manus-agent-token"
- 選擇過期時間
- 選擇權限範圍(scopes):
- ✅
repo(完整倉庫訪問)repo:statusrepo_deploymentpublic_reporepo:invite
- ✅
workflow(如果需要修改 GitHub Actions) - ✅
write:packages(如果需要訪問包)
- ✅
- 點擊
Generate token
- 立即複製生成的 token
- 將其保存在安全的地方(如密碼管理器)
- 不要在代碼或公共位置分享此 token
Token 格式示例:
ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx # Classic token
github_pat_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx # Fine-grained token
-
環境變量方式(推薦):
export GITHUB_TOKEN="your_token_here"
-
配置文件方式: 創建
.env文件(確保已添加到.gitignore):GITHUB_TOKEN=your_token_here GITHUB_REPO=GreatTribulaton2028/- -
直接在 manus-agent 配置中使用: 根據 manus-agent 的具體文檔進行配置
使用 GitHub API 驗證 token:
curl -H "Authorization: token YOUR_TOKEN" \
https://api.github.com/user或驗證倉庫訪問:
curl -H "Authorization: token YOUR_TOKEN" \
https://api.github.com/repos/GreatTribulaton2028/-git clone https://YOUR_TOKEN@github.com/GreatTribulaton2028/-.git或設置為遠程:
git remote set-url origin https://YOUR_TOKEN@github.com/GreatTribulaton2028/-.git- ✅ 定期輪換 Token: 每 90 天更新一次
- ✅ 最小權限原則: 只授予必要的權限
- ✅ 監控使用情況: 定期檢查 token 的使用日誌
- ✅ 立即撤銷: 如果 token 洩露,立即在 GitHub 設置中撤銷
- ✅ 不要提交到代碼: 始終使用環境變量或安全存儲
- ✅ 使用 Fine-grained tokens: 比 classic tokens 更安全
A: 返回 GitHub Developer settings,生成新的 token 並更新配置。
A: 前往 Settings → Developer settings → Personal access tokens,找到對應的 token,點擊 Delete 或 Revoke。
A: 至少需要 repo 範圍(對於 classic tokens)或 Contents: Read and write + Pull requests: Read and write(對於 fine-grained tokens)。
A: Classic tokens 可以訪問所有倉庫(根據權限),Fine-grained tokens 可以在創建時選擇特定倉庫。
如有問題,請在倉庫中創建 Issue 或聯繫維護者。
本文檔最後更新: 2026-01-27