create-pr
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseHow to Create a Pull Request Using GitHub CLI
如何使用GitHub CLI创建拉取请求
This guide explains how to create pull requests using GitHub CLI in our project.
Important: All PR titles and descriptions should be written in English.
本指南说明如何在我们的项目中使用GitHub CLI创建拉取请求。
重要提示:所有PR标题和描述都必须使用英文撰写。
Prerequisites
前提条件
Check if is installed, if not follow this instruction to install it:
gh-
Install GitHub CLI if you haven't already:bash
# macOS brew install gh # Windows winget install --id GitHub.cli # Linux # Follow instructions at https://github.com/cli/cli/blob/trunk/docs/install_linux.md -
Authenticate with GitHub:bash
gh auth login
检查是否已安装,如果未安装,请按照以下说明进行安装:
gh-
安装GitHub CLI(如果尚未安装):bash
# macOS brew install gh # Windows winget install --id GitHub.cli # Linux # 按照https://github.com/cli/cli/blob/trunk/docs/install_linux.md上的说明操作 -
与GitHub进行身份验证:bash
gh auth login
Pre-flight Checks
预检查
Before creating a PR, check for uncommitted changes:
- Run to check for uncommitted changes (staged, unstaged, or untracked files)
git status - If uncommitted changes exist, use the Skill tool to run the skill first:
commitSkill: commit - This ensures all your work is committed before creating the PR
在创建PR之前,检查是否有未提交的更改:
- 运行检查未提交的更改(已暂存、未暂存或未跟踪的文件)
git status - 如果存在未提交的更改,请先使用Skill工具运行技能:
commitSkill: commit - 这确保你在创建PR之前已提交所有工作内容
Creating a New Pull Request
创建新的拉取请求
-
First, prepare your PR description following the template in @.github/pull_request_template.md
-
Use thecommand to create a new pull request:
gh pr create --draftbash# Basic command structure gh pr create --draft --title "✨(scope): Your descriptive title" --body "Your PR description" --base mainFor more complex PR descriptions with proper formatting, use theoption with the exact PR template structure:--body-filebash# Create PR with proper template structure gh pr create --draft --title "✨(scope): Your descriptive title" --body-file .github/pull_request_template.md --base main
-
首先,按照@.github/pull_request_template.md中的模板准备你的PR描述
-
使用命令创建新的拉取请求:
gh pr create --draftbash# 基础命令结构 gh pr create --draft --title "✨(scope): Your descriptive title" --body "Your PR description" --base main对于格式规范的更复杂PR描述,请结合选项使用完整的PR模板结构:--body-filebash# 使用规范模板结构创建PR gh pr create --draft --title "✨(scope): Your descriptive title" --body-file .github/pull_request_template.md --base main
Best Practices
最佳实践
-
Language: Always use English for PR titles and descriptions
-
PR Title Format: Use conventional commit format with emojis
- Always include an appropriate emoji at the beginning of the title
- Use the actual emoji character (not the code representation like )
:sparkles: - Examples:
✨(supabase): Add staging remote configuration🐛(auth): Fix login redirect issue📝(readme): Update installation instructions
-
Description Template: Always use our PR template structure from @.github/pull_request_template.md:
-
Template Accuracy: Ensure your PR description precisely follows the template structure:
- Don't modify or rename the PR-Agent sections (and
pr_agent:summary)pr_agent:walkthrough - Keep all section headers exactly as they appear in the template
- Don't add custom sections that aren't in the template
- Don't modify or rename the PR-Agent sections (
-
Draft PRs: Start as draft when the work is in progress
- Use flag in the command
--draft - Convert to ready for review when complete using
gh pr ready
- Use
-
语言:PR标题和描述始终使用英文
-
PR标题格式:使用带有表情符号的约定式提交格式
- 标题开头必须包含合适的表情符号
- 使用实际的表情符号字符(而非这类代码表示)
:sparkles: - 示例:
✨(supabase): Add staging remote configuration🐛(auth): Fix login redirect issue📝(readme): Update installation instructions
-
描述模板:始终使用我们从@.github/pull_request_template.md获取的PR模板结构:
-
模板准确性:确保你的PR描述严格遵循模板结构:
- 不要修改或重命名PR-Agent部分(和
pr_agent:summary)pr_agent:walkthrough - 保持所有章节标题与模板中的完全一致
- 不要添加模板中未定义的自定义章节
- 不要修改或重命名PR-Agent部分(
-
草稿PR:当工作仍在进行中时,以草稿形式创建
- 在命令中使用标志
--draft - 完成后使用将其转换为待审核状态
gh pr ready
- 在命令中使用
Common Mistakes to Avoid
需避免的常见错误
- Using Non-English Text: All PR content must be in English
- Incorrect Section Headers: Always use the exact section headers from the template
- Adding Custom Sections: Stick to the sections defined in the template
- Using Outdated Templates: Always refer to the current @.github/pull_request_template.md file
- 使用非英文文本:所有PR内容必须使用英文
- 章节标题错误:始终使用模板中的准确章节标题
- 添加自定义章节:严格遵循模板中定义的章节
- 使用过时模板:始终参考当前的@.github/pull_request_template.md文件
Missing Sections
缺失章节
Always include all template sections, even if some are marked as "N/A" or "None"
始终包含模板的所有章节,即使某些章节标记为"N/A"或"None"
Additional GitHub CLI PR Commands
其他GitHub CLI PR命令
Here are some additional useful GitHub CLI commands for managing PRs:
bash
undefined以下是一些用于管理PR的实用GitHub CLI命令:
bash
undefinedList your open pull requests
列出你所有的开放拉取请求
gh pr list --author "@me"
gh pr list --author "@me"
Check PR status
检查PR状态
gh pr status
gh pr status
View a specific PR
查看特定PR
gh pr view <PR-NUMBER>
gh pr view <PR-NUMBER>
Check out a PR branch locally
在本地检出PR分支
gh pr checkout <PR-NUMBER>
gh pr checkout <PR-NUMBER>
Convert a draft PR to ready for review
将草稿PR转换为待审核状态
gh pr ready <PR-NUMBER>
gh pr ready <PR-NUMBER>
Add reviewers to a PR
为PR添加审核人
gh pr edit <PR-NUMBER> --add-reviewer username1,username2
gh pr edit <PR-NUMBER> --add-reviewer username1,username2
Merge a PR
合并PR
gh pr merge <PR-NUMBER> --squash
undefinedgh pr merge <PR-NUMBER> --squash
undefinedUsing Templates for PR Creation
使用模板创建PR
To simplify PR creation with consistent descriptions, you can create a template file:
- Create a file named with your PR template
pr-template.md - Use it when creating PRs:
bash
gh pr create --draft --title "feat(scope): Your title" --body-file pr-template.md --base main为简化PR创建并保持描述一致性,你可以创建一个模板文件:
- 创建名为的文件,写入你的PR模板
pr-template.md - 创建PR时使用该文件:
bash
gh pr create --draft --title "feat(scope): Your title" --body-file pr-template.md --base mainRelated Documentation
相关文档
- PR Template
- Conventional Commits
- GitHub CLI documentation
- PR模板
- 约定式提交
- GitHub CLI文档