github-pr
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseWhen to Use
适用场景
- Creating a new Pull Request
- Writing PR titles and descriptions
- Preparing commits for review
- Using command
gh pr create
- 创建新的Pull Request
- 编写PR标题和描述
- 准备用于评审的提交
- 使用 命令
gh pr create
Critical Patterns
核心规范
PR Title = Conventional Commit
PR标题遵循Conventional Commit规范
<type>(<scope>): <short description>
feat New feature
fix Bug fix
docs Documentation
refactor Code refactoring
test Adding tests
chore Maintenance<type>(<scope>): <short description>
feat 新功能
fix 修复Bug
docs 文档更新
refactor 代码重构
test 添加测试
chore 维护工作PR Description Structure
PR描述结构
markdown
undefinedmarkdown
undefinedSummary
概述
- 1-3 bullet points explaining WHAT and WHY
- 用1-3个要点说明做了什么以及为什么这么做
Changes
变更内容
- List main changes
- 列出主要变更
Testing
测试情况
- Tests added/updated
- Manual testing done
Closes #123
undefined- 新增/更新测试
- 完成手动测试
Closes #123
undefinedAtomic Commits
原子提交
bash
undefinedbash
undefinedGood: One thing per commit
推荐:每个提交只做一件事
git commit -m "feat(user): add User model"
git commit -m "feat(user): add UserService"
git commit -m "test(user): add UserService tests"
git commit -m "feat(user): add User model"
git commit -m "feat(user): add UserService"
git commit -m "test(user): add UserService tests"
Bad: Everything in one commit
不推荐:所有内容放在一个提交里
git commit -m "add user feature"
---git commit -m "add user feature"
---Code Examples
代码示例
Basic PR Creation
基础PR创建
bash
gh pr create \
--title "feat(auth): add OAuth2 login" \
--body "## Summary
- Add Google OAuth2 authenticationbash
gh pr create \
--title "feat(auth): add OAuth2 login" \
--body "## 概述
- 添加Google OAuth2认证功能Changes
变更内容
- Added AuthProvider component
- Created useAuth hook
Closes #42"
undefined- 新增AuthProvider组件
- 实现useAuth钩子
Closes #42"
undefinedPR with HEREDOC (Complex Description)
使用HEREDOC的PR(复杂描述)
bash
gh pr create --title "feat(dashboard): add analytics" --body "$(cat <<'EOF'bash
gh pr create --title "feat(dashboard): add analytics" --body "$(cat <<'EOF'Summary
概述
- Add real-time analytics dashboard
- 添加实时数据分析仪表盘
Changes
变更内容
- Created AnalyticsProvider
- Added LineChart, BarChart components
- 实现AnalyticsProvider
- 新增LineChart、BarChart组件
Testing
测试情况
- Unit tests for components
- Manual testing complete
- 组件单元测试完成
- 手动测试完成
Screenshots
截图
Closes #123
EOF
)"
undefinedCloses #123
EOF
)"
undefinedDraft PR
草稿PR
bash
gh pr create --draft \
--title "wip: refactor auth" \
--body "Work in progress"bash
gh pr create --draft \
--title "wip: refactor auth" \
--body "Work in progress"PR with Reviewers and Labels
指定评审人和标签的PR
bash
gh pr create \
--title "feat(api): add rate limiting" \
--body "Adds rate limiting to API" \
--reviewer "user1,user2" \
--label "enhancement,api"bash
gh pr create \
--title "feat(api): add rate limiting" \
--body "为API添加限流功能" \
--reviewer "user1,user2" \
--label "enhancement,api"Commands
常用命令
bash
undefinedbash
undefinedCreate PR
创建PR
gh pr create --title "type(scope): desc" --body "..."
gh pr create --title "type(scope): desc" --body "..."
Create with web editor
使用网页编辑器创建
gh pr create --web
gh pr create --web
View PR status
查看PR状态
gh pr status
gh pr status
View diff
查看差异
gh pr diff
gh pr diff
Check CI status
检查CI状态
gh pr checks
gh pr checks
Merge with squash
以合并压缩方式合并PR
gh pr merge --squash
gh pr merge --squash
Add reviewer
添加评审人
gh pr edit --add-reviewer username
---gh pr edit --add-reviewer username
---Anti-Patterns
反模式
Don't: Vague Titles
避免:模糊的标题
bash
undefinedbash
undefinedBad
不推荐
gh pr create --title "fix bug"
gh pr create --title "update"
gh pr create --title "fix bug"
gh pr create --title "update"
Good
推荐
gh pr create --title "fix(auth): prevent session timeout"
undefinedgh pr create --title "fix(auth): prevent session timeout"
undefinedDon't: Giant PRs
避免:超大PR
bash
undefinedbash
undefinedBad: 50 files, 2000+ lines in one PR
不推荐:一个PR包含50个文件、2000+行代码
Good: Split into logical PRs
推荐:拆分为多个逻辑独立的PR
PR 1: feat(models): add User model
PR 1: feat(models): add User model
PR 2: feat(api): add user endpoints
PR 2: feat(api): add user endpoints
PR 3: feat(ui): add user pages
PR 3: feat(ui): add user pages
undefinedundefinedDon't: Empty Descriptions
避免:空描述
bash
undefinedbash
undefinedBad
不推荐
--body "Added feature"
--body "Added feature"
Good
推荐
--body "## Summary
- What you did and why
--body "## 概述
- 你做了什么以及这么做的原因
Changes
变更内容
- Specific changes
Closes #123"
---- 具体变更点
Closes #123"
---Quick Reference
速查表
| Task | Command |
|---|---|
| Create PR | |
| Draft PR | |
| Web editor | |
| Add reviewer | |
| Add label | |
| Link issue | |
| View status | |
| Merge squash | |
| 任务 | 命令 |
|---|---|
| 创建PR | |
| 创建草稿PR | |
| 使用网页编辑器 | |
| 添加评审人 | |
| 添加标签 | |
| 关联Issue | 在描述中添加 |
| 查看PR状态 | |
| 合并压缩PR | |