|
| 1 | +# How to Create a Pull Request Using GitHub CLI |
| 2 | + |
| 3 | +This guide explains how to create pull requests using GitHub CLI in our project. |
| 4 | + |
| 5 | +**Important**: All PR titles and descriptions should be written in English. |
| 6 | + |
| 7 | +## Prerequisites |
| 8 | + |
| 9 | +1. Install GitHub CLI if you haven't already: |
| 10 | + |
| 11 | + ```bash |
| 12 | + # macOS |
| 13 | + brew install gh |
| 14 | + |
| 15 | + # Windows |
| 16 | + winget install --id GitHub.cli |
| 17 | + |
| 18 | + # Linux |
| 19 | + # Follow instructions at https://github.com/cli/cli/blob/trunk/docs/install_linux.md |
| 20 | + ``` |
| 21 | + |
| 22 | +2. Authenticate with GitHub: |
| 23 | + ```bash |
| 24 | + gh auth login |
| 25 | + ``` |
| 26 | + |
| 27 | +## Creating a New Pull Request |
| 28 | + |
| 29 | +1. First, prepare your PR description following the template in @.github/pull_request_template.md |
| 30 | + |
| 31 | +2. Use the `gh pr create --draft` command to create a new pull request: |
| 32 | + |
| 33 | + ```bash |
| 34 | + # Create PR with proper template structure |
| 35 | + gh pr create --draft --title "✨(scope): Your descriptive title" --body-file .github/pull_request_template.md --base main |
| 36 | + ``` |
| 37 | + |
| 38 | +## Best Practices |
| 39 | + |
| 40 | +1. **Language**: Always use English for PR titles and descriptions |
| 41 | + |
| 42 | +2. **PR Title Format**: Use conventional commit format with emojis |
| 43 | + |
| 44 | + - Always include an appropriate emoji at the beginning of the title |
| 45 | + - Use the actual emoji character (not the code representation like `:sparkles:`) |
| 46 | + - Examples: |
| 47 | + - `✨(supabase): Add staging remote configuration` |
| 48 | + - `🐛(auth): Fix login redirect issue` |
| 49 | + - `📝(readme): Update installation instructions` |
| 50 | + |
| 51 | +3. **Description Template**: Always use our PR template structure from @.github/pull_request_template.md: |
| 52 | + |
| 53 | +4. **Template Accuracy**: Ensure your PR description precisely follows the template structure: |
| 54 | + |
| 55 | + - Don't modify or rename the PR-Agent sections (`pr_agent:summary` and `pr_agent:walkthrough`) |
| 56 | + - Keep all section headers exactly as they appear in the template |
| 57 | + - Don't add custom sections that aren't in the template |
| 58 | + |
| 59 | +5. **Draft PRs**: Start as draft when the work is in progress |
| 60 | + - Use `--draft` flag in the command |
| 61 | + - Convert to ready for review when complete using `gh pr ready` |
| 62 | + |
| 63 | +### Common Mistakes to Avoid |
| 64 | + |
| 65 | +1. **Using Non-English Text**: All PR content must be in English |
| 66 | +2. **Incorrect Section Headers**: Always use the exact section headers from the template |
| 67 | +3. **Adding Custom Sections**: Stick to the sections defined in the template |
| 68 | +4. **Using Outdated Templates**: Always refer to the current @.github/pull_request_template.md file |
| 69 | + |
| 70 | +### Missing Sections |
| 71 | + |
| 72 | +Always include all template sections, even if some are marked as "N/A" or "None" |
| 73 | + |
| 74 | +## Additional GitHub CLI PR Commands |
| 75 | + |
| 76 | +Here are some additional useful GitHub CLI commands for managing PRs: |
| 77 | + |
| 78 | +```bash |
| 79 | +# List your open pull requests |
| 80 | +gh pr list --author "@me" |
| 81 | + |
| 82 | +# Check PR status |
| 83 | +gh pr status |
| 84 | + |
| 85 | +# View a specific PR |
| 86 | +gh pr view <PR-NUMBER> |
| 87 | + |
| 88 | +# Check out a PR branch locally |
| 89 | +gh pr checkout <PR-NUMBER> |
| 90 | + |
| 91 | +# Convert a draft PR to ready for review |
| 92 | +gh pr ready <PR-NUMBER> |
| 93 | + |
| 94 | +# Add reviewers to a PR |
| 95 | +gh pr edit <PR-NUMBER> --add-reviewer username1,username2 |
| 96 | + |
| 97 | +# Merge a PR |
| 98 | +gh pr merge <PR-NUMBER> --squash |
| 99 | +``` |
| 100 | + |
| 101 | +## Using Templates for PR Creation |
| 102 | + |
| 103 | +To simplify PR creation with consistent descriptions, you can create a template file: |
| 104 | + |
| 105 | +1. Create a file named `pr-template.md` with your PR template |
| 106 | +2. Use it when creating PRs: |
| 107 | + |
| 108 | +```bash |
| 109 | +gh pr create --draft --title "feat(scope): Your title" --body-file pr-template.md --base main |
| 110 | +``` |
| 111 | + |
| 112 | +## Related Documentation |
| 113 | + |
| 114 | +- [PR Template](.github/pull_request_template.md) |
| 115 | +- [Conventional Commits](https://www.conventionalcommits.org/) |
| 116 | +- [GitHub CLI documentation](https://cli.github.com/manual/) |
0 commit comments