This command commits current work, pushes to the appropriate branch, and creates a pull request when needed.
- NEVER push directly to
main,masterordevelopbranches - If currently on
main,masterordevelop, create a new branch first - Generate meaningful commit messages based on the actual changes
- Generate meaningful branch names in kebab-case (e.g.,
feat/add-user-authentication,fix/null-pointer-in-parser) - Skip PR creation if a PR already exists for the current branch
- Use the repository's default branch as the PR base
Run this command to determine the current branch:
git branch --show-current- If the branch is
main,masterordevelop, proceed to Step 2 (create new branch) - If on any other branch, skip to Step 3 (stage and commit)
First, analyze the changes to generate a meaningful branch name:
git status --short
git diff --statBased on the changes observed:
- Determine the type:
feat/,fix/,chore/,refactor/,docs/,test/ - Create a descriptive kebab-case name summarizing the work
- Example names:
feat/add-discord-notifications,fix/handle-empty-response,chore/update-dependencies
Create and switch to the new branch:
git checkout -b <branch-name>Check what files have been modified:
git status --shortStage the relevant files. Exclude local configuration files like .vscode/, .cursor/, .idea/, etc.:
git add <files-to-stage>Or to stage all relevant changes:
git add -AThen unstage any local config files if they were accidentally added:
git reset HEAD .vscode/ .cursor/ .idea/ 2>/dev/null || trueReview the staged changes to create a meaningful commit message:
git diff --cached --stat
git diff --cachedCreate a conventional commit with:
- Format:
type: short description - Types:
feat:,fix:,chore:,refactor:,docs:,test:,perf: - Body: Include detailed bullet points of key changes if needed
Commit the changes:
git commit -m "type: short description" -m "- Detail 1
- Detail 2
- Detail 3"Or for simple commits:
git commit -m "type: short description"Push the branch to origin. Use -u flag if it's a new branch:
git push -u origin $(git branch --show-current)Or if the branch already exists on remote:
git push origin $(git branch --show-current)Before creating a PR, check if one already exists for this branch:
gh pr list --head $(git branch --show-current) --state open- If a PR already exists, skip PR creation and proceed to the summary
- If no PR exists, proceed to Step 7
First, get the repository's default branch:
gh repo view --json defaultBranchRef --jq '.defaultBranchRef.name'Create the pull request using the default branch as base:
gh pr create --base <default-branch> --title "<PR Title>" --body "<PR Body>"PR Title: Should match or expand on the commit message summary
PR Body Format:
## Summary
Brief description of what this PR does.
## Changes
- **File/Component**: Description of change
- **File/Component**: Description of change
## Testing
How it was tested / which tests were added.
After completing all steps, provide a summary with:
- Branch name: The branch that was pushed to
- Commit message: The commit message that was used
- PR URL: The URL of the created PR (or note if PR already existed/was skipped)
- Status: Success or any issues encountered
Example summary format:
β
Successfully committed and pushed!
π Branch: feat/add-user-notifications
π Commit: feat(notifications): add Discord webhook integration
π PR: https://github.com/owner/repo/pull/123
Or if PR already existed:
β
Successfully committed and pushed!
π Branch: feat/add-user-notifications
π Commit: feat(notifications): add Discord webhook integration
βΉοΈ PR already exists - skipped PR creation