Git PR
Complete git workflow from local changes to Pull Request.
Phase 1: Pre-flight Check
Actions:
git status- check for changesgit branch --show-current- get current branch- Warn if on main/master branch
- Check remote tracking:
git rev-parse --abbrev-ref @{u}
Phase 2: Commit Changes
If uncommitted changes exist:
- Follow
/git:commitworkflow - Skip if no changes
Phase 3: Push to Remote
Actions:
- Check remote branch:
git ls-remote --heads origin <branch> - If not exists:
git push -u origin <branch> - If exists:
git push - Handle push conflicts (suggest
git pull --rebase)
Phase 4: Create Pull Request
Actions:
- Determine target branch (default: main, or from
$ARGUMENTS) - Get commits:
git log main..<branch> --oneline - Generate PR content:
## Summary - Key changes description ## Changes - List based on commits ## Testing - How to verify - Create PR:
gh pr create --title "<title>" --body "<body>" --base <target> - Return PR URL
Error Handling
| Situation | Action |
|---|---|
No gh CLI |
Provide manual instructions |
| Push rejected | Suggest git pull --rebase |
| On main branch | Ask to create feature branch first |
Output Language
- Status messages: Chinese
- PR title/body: English