github-projects
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGitHub Projects CLI
GitHub Projects CLI
GitHub Projects (v2) management via commands. Requires the scope which can be added with .
gh projectprojectgh auth refresh -s project通过命令管理GitHub Projects (v2)。需要权限范围,可通过添加。
gh projectprojectgh auth refresh -s projectPrerequisites
前提条件
Verify authentication includes project scope:
bash
gh auth status # Check current scopes
gh auth refresh -s project # Add project scope if missing验证身份验证是否包含project权限范围:
bash
gh auth status # 检查当前权限范围
gh auth refresh -s project # 若缺失则添加project权限范围Quick Reference
快速参考
List & View Projects
列出与查看项目
bash
undefinedbash
undefinedList your projects
列出你的项目
gh project list
gh project list
List org projects (including closed)
列出组织项目(包括已关闭的)
gh project list --owner ORG_NAME --closed
gh project list --owner ORG_NAME --closed
View project details
查看项目详情
gh project view PROJECT_NUM --owner OWNER
gh project view PROJECT_NUM --owner OWNER
Open in browser
在浏览器中打开
gh project view PROJECT_NUM --owner OWNER --web
gh project view PROJECT_NUM --owner OWNER --web
JSON output with jq filtering
结合jq过滤的JSON输出
gh project list --format json | jq '.projects[] | {number, title}'
undefinedgh project list --format json | jq '.projects[] | {number, title}'
undefinedCreate & Edit Projects
创建与编辑项目
bash
undefinedbash
undefinedCreate project
创建项目
gh project create --owner OWNER --title "Project Title"
gh project create --owner OWNER --title "Project Title"
Edit project
编辑项目
gh project edit PROJECT_NUM --owner OWNER --title "New Title"
gh project edit PROJECT_NUM --owner OWNER --description "New description"
gh project edit PROJECT_NUM --owner OWNER --visibility PUBLIC
gh project edit PROJECT_NUM --owner OWNER --title "New Title"
gh project edit PROJECT_NUM --owner OWNER --description "New description"
gh project edit PROJECT_NUM --owner OWNER --visibility PUBLIC
Close/reopen project
关闭/重新打开项目
gh project close PROJECT_NUM --owner OWNER
gh project close PROJECT_NUM --owner OWNER --undo # Reopen
undefinedgh project close PROJECT_NUM --owner OWNER
gh project close PROJECT_NUM --owner OWNER --undo # 重新打开
undefinedLink Projects to Repos
关联项目与仓库
bash
undefinedbash
undefinedLink to repo
关联到仓库
gh project link PROJECT_NUM --owner OWNER --repo REPO_NAME
gh project link PROJECT_NUM --owner OWNER --repo REPO_NAME
Link to team
关联到团队
gh project link PROJECT_NUM --owner ORG --team TEAM_NAME
gh project link PROJECT_NUM --owner ORG --team TEAM_NAME
Unlink
取消关联
gh project unlink PROJECT_NUM --owner OWNER --repo REPO_NAME
undefinedgh project unlink PROJECT_NUM --owner OWNER --repo REPO_NAME
undefinedProject Items
项目事项
Add Existing Issues/PRs
添加现有议题/拉取请求
bash
undefinedbash
undefinedAdd issue to project
向项目添加议题
gh project item-add PROJECT_NUM --owner OWNER --url https://github.com/OWNER/REPO/issues/123
gh project item-add PROJECT_NUM --owner OWNER --url https://github.com/OWNER/REPO/issues/123
Add PR to project
向项目添加拉取请求
gh project item-add PROJECT_NUM --owner OWNER --url https://github.com/OWNER/REPO/pull/456
undefinedgh project item-add PROJECT_NUM --owner OWNER --url https://github.com/OWNER/REPO/pull/456
undefinedCreate Draft Items
创建草稿事项
bash
gh project item-create PROJECT_NUM --owner OWNER --title "Draft item" --body "Description"bash
gh project item-create PROJECT_NUM --owner OWNER --title "Draft item" --body "Description"List Items
列出事项
bash
undefinedbash
undefinedList items (default 30)
列出事项(默认30条)
gh project item-list PROJECT_NUM --owner OWNER
gh project item-list PROJECT_NUM --owner OWNER
List more items
列出更多事项
gh project item-list PROJECT_NUM --owner OWNER --limit 100
gh project item-list PROJECT_NUM --owner OWNER --limit 100
JSON output
JSON输出
gh project item-list PROJECT_NUM --owner OWNER --format json
undefinedgh project item-list PROJECT_NUM --owner OWNER --format json
undefinedEdit Items
编辑事项
Items are edited by their ID (obtained from ).
item-list --format jsonbash
undefined事项需通过其ID(从获取)进行编辑。
item-list --format jsonbash
undefinedEdit draft issue title/body
编辑草稿议题的标题/正文
gh project item-edit --id ITEM_ID --title "New Title" --body "New body"
gh project item-edit --id ITEM_ID --title "New Title" --body "New body"
Update field value (requires field-id and project-id)
更新字段值(需要field-id和project-id)
gh project item-edit --id ITEM_ID --project-id PROJECT_ID --field-id FIELD_ID --text "value"
gh project item-edit --id ITEM_ID --project-id PROJECT_ID --field-id FIELD_ID --number 42
gh project item-edit --id ITEM_ID --project-id PROJECT_ID --field-id FIELD_ID --date "2024-12-31"
gh project item-edit --id ITEM_ID --project-id PROJECT_ID --field-id FIELD_ID --single-select-option-id OPTION_ID
gh project item-edit --id ITEM_ID --project-id PROJECT_ID --field-id FIELD_ID --iteration-id ITER_ID
gh project item-edit --id ITEM_ID --project-id PROJECT_ID --field-id FIELD_ID --text "value"
gh project item-edit --id ITEM_ID --project-id PROJECT_ID --field-id FIELD_ID --number 42
gh project item-edit --id ITEM_ID --project-id PROJECT_ID --field-id FIELD_ID --date "2024-12-31"
gh project item-edit --id ITEM_ID --project-id PROJECT_ID --field-id FIELD_ID --single-select-option-id OPTION_ID
gh project item-edit --id ITEM_ID --project-id PROJECT_ID --field-id FIELD_ID --iteration-id ITER_ID
Clear field value
清空字段值
gh project item-edit --id ITEM_ID --project-id PROJECT_ID --field-id FIELD_ID --clear
undefinedgh project item-edit --id ITEM_ID --project-id PROJECT_ID --field-id FIELD_ID --clear
undefinedArchive/Delete Items
归档/删除事项
bash
gh project item-archive PROJECT_NUM --owner OWNER --id ITEM_ID
gh project item-delete PROJECT_NUM --owner OWNER --id ITEM_IDbash
gh project item-archive PROJECT_NUM --owner OWNER --id ITEM_ID
gh project item-delete PROJECT_NUM --owner OWNER --id ITEM_IDProject Fields
项目字段
List Fields
列出字段
bash
gh project field-list PROJECT_NUM --owner OWNER
gh project field-list PROJECT_NUM --owner OWNER --format jsonbash
gh project field-list PROJECT_NUM --owner OWNER
gh project field-list PROJECT_NUM --owner OWNER --format jsonCreate Fields
创建字段
bash
undefinedbash
undefinedText field
文本字段
gh project field-create PROJECT_NUM --owner OWNER --name "Notes" --data-type TEXT
gh project field-create PROJECT_NUM --owner OWNER --name "Notes" --data-type TEXT
Number field
数字字段
gh project field-create PROJECT_NUM --owner OWNER --name "Points" --data-type NUMBER
gh project field-create PROJECT_NUM --owner OWNER --name "Points" --data-type NUMBER
Date field
日期字段
gh project field-create PROJECT_NUM --owner OWNER --name "Due Date" --data-type DATE
gh project field-create PROJECT_NUM --owner OWNER --name "Due Date" --data-type DATE
Single select with options
带选项的单选字段
gh project field-create PROJECT_NUM --owner OWNER --name "Priority"
--data-type SINGLE_SELECT
--single-select-options "Low,Medium,High,Critical"
--data-type SINGLE_SELECT
--single-select-options "Low,Medium,High,Critical"
undefinedgh project field-create PROJECT_NUM --owner OWNER --name "Priority"
--data-type SINGLE_SELECT
--single-select-options "Low,Medium,High,Critical"
--data-type SINGLE_SELECT
--single-select-options "Low,Medium,High,Critical"
undefinedDelete Fields
删除字段
bash
gh project field-delete --id FIELD_IDbash
gh project field-delete --id FIELD_IDCommon Workflows
常见工作流
Add Issue and Set Status
添加议题并设置状态
bash
undefinedbash
undefined1. Add issue to project
1. 向项目添加议题
gh project item-add 1 --owner "@me" --url https://github.com/owner/repo/issues/123
gh project item-add 1 --owner "@me" --url https://github.com/owner/repo/issues/123
2. Get item ID and field IDs
2. 获取事项ID和字段ID
gh project item-list 1 --owner "@me" --format json | jq '.items[-1]'
gh project field-list 1 --owner "@me" --format json
gh project item-list 1 --owner "@me" --format json | jq '.items[-1]'
gh project field-list 1 --owner "@me" --format json
3. Update status field
3. 更新状态字段
gh project item-edit --id ITEM_ID --project-id PROJECT_ID
--field-id STATUS_FIELD_ID --single-select-option-id OPTION_ID
--field-id STATUS_FIELD_ID --single-select-option-id OPTION_ID
undefinedgh project item-edit --id ITEM_ID --project-id PROJECT_ID
--field-id STATUS_FIELD_ID --single-select-option-id OPTION_ID
--field-id STATUS_FIELD_ID --single-select-option-id OPTION_ID
undefinedBulk Add Issues
批量添加议题
bash
undefinedbash
undefinedAdd all open issues from a repo
添加仓库中所有开放的议题
gh issue list --repo owner/repo --state open --json url -q '.[].url' |
xargs -I {} gh project item-add 1 --owner "@me" --url {}
xargs -I {} gh project item-add 1 --owner "@me" --url {}
undefinedgh issue list --repo owner/repo --state open --json url -q '.[].url' |
xargs -I {} gh project item-add 1 --owner "@me" --url {}
xargs -I {} gh project item-add 1 --owner "@me" --url {}
undefinedJSON Output & jq Patterns
JSON输出与jq模式
bash
undefinedbash
undefinedGet project IDs
获取项目ID
gh project list --format json | jq '.projects[] | {number, id, title}'
gh project list --format json | jq '.projects[] | {number, id, title}'
Get field IDs and options
获取字段ID和选项
gh project field-list 1 --owner "@me" --format json | jq '.fields[] | {id, name, options}'
gh project field-list 1 --owner "@me" --format json | jq '.fields[] | {id, name, options}'
Get item IDs with field values
获取带有字段值的事项ID
gh project item-list 1 --owner "@me" --format json | jq '.items[] | {id, title, fieldValues}'
gh project item-list 1 --owner "@me" --format json | jq '.items[] | {id, title, fieldValues}'
Filter items by status
按状态过滤事项
gh project item-list 1 --owner "@me" --format json |
jq '.items[] | select(.status == "In Progress")'
jq '.items[] | select(.status == "In Progress")'
undefinedgh project item-list 1 --owner "@me" --format json |
jq '.items[] | select(.status == "In Progress")'
jq '.items[] | select(.status == "In Progress")'
undefinedReference Files
参考文件
- items.md: Item management, editing field values, bulk operations
- fields.md: Field types, creating custom fields, option management
- items.md: 事项管理、编辑字段值、批量操作
- fields.md: 字段类型、创建自定义字段、选项管理
Command Summary
命令汇总
| Command | Purpose |
|---|---|
| List projects |
| View project details |
| Create new project |
| Modify project settings |
| Close/reopen project |
| Connect to repo/team |
| Add existing issue/PR |
| Create draft item |
| List project items |
| Update item fields |
| Archive item |
| Remove item |
| List project fields |
| Add custom field |
| Remove field |
| 命令 | 用途 |
|---|---|
| 列出项目 |
| 查看项目详情 |
| 创建新项目 |
| 修改项目设置 |
| 关闭/重新打开项目 |
| 关联到仓库/团队 |
| 添加现有议题/拉取请求 |
| 创建草稿事项 |
| 列出项目事项 |
| 更新事项字段 |
| 归档事项 |
| 删除事项 |
| 列出项目字段 |
| 添加自定义字段 |
| 删除字段 |