Git & GitHub Workflows
Quick Reference
| Action | Trigger phrases |
|---|---|
| Sync with remote | "pull", "sync", "update from main" |
| Commit changes | "commit", "save changes" |
| Create pull request | "PR", "create a PR", "submit for review" |
| Reset to main | "reset to main", "start fresh" |
Workflow Composition
Workflows build on each other:
code
PR → Commit → Pull
- •Creating PR first commits changes
- •Committing first pulls latest from main
Pull Workflow
Pull latest changes and sync with remote.
Scope
- •Single repo: If specific repo mentioned or clearly working in one, only pull that repo
- •All repos: If "all" is said or unspecified, pull all git repos in workspace
On main branch
- •Clean working directory:
git pull origin main - •Has uncommitted changes:
git stash && git pull origin main && git stash pop— resolve conflicts but do NOT push
On feature branch
- •Merge latest main:
git fetch origin && git merge origin/main - •Push the branch:
git push
Rules
- •Never force push
- •Summarize results for each repo
Commit Workflow
Commit changes to current branch.
Before Committing
- •Pull latest - Sync with main using pull workflow
- •Run checks - Lint, format, build, test, and any repo-specific commands
- •Fix issues - Fix all warnings and errors
Commit
- •Stage relevant changes
- •Write clear, concise commit message focused on the "why"
- •Commit the changes
PR Workflow
Create a PR against main.
Before Creating PR
- •Pull and merge main - Always fetch and merge latest main first:
Resolve any merge conflicts before proceeding.bash
git fetch origin && git merge origin/main
- •Commit changes - Apply commit workflow (runs checks)
- •Create new branch if needed
Create the PR
- •Push to remote (with
-uflag if new branch) - •Create PR using
ghCLI - •Open browser tab to the PR's
/filespage:open <pr-url>/files - •Return the PR URL as clickable markdown link:
[PR #N](url)
Output Format
Always format URLs as clickable markdown links:
- •PR link:
[PR #123](https://github.com/owner/repo/pull/123) - •Any other URLs should also be linked
Monitor CI
Use gh CLI to monitor CI status. If CI fails:
- •Investigate the failure
- •Fix the issue
- •Push the fix
- •Repeat until CI passes
After CI Passes
Check PR for auto-fixable review feedback:
- •Fetch PR comments and reviews using
gh api - •Review bot feedback for actionable suggestions
- •Fix issues that can be resolved without human input
- •Push fixes and reply to comments acknowledging changes
- •Repeat until no more auto-fixable feedback remains
Reset to Main Workflow
Reset repos to clean main branch state.
Trigger
- •"reset to main", "start fresh", "clean slate"
Process
For each git repo in workspace:
- •Check for uncommitted changes:
git status --porcelain - •If changes exist: Stash with descriptive message
bash
git stash push -m "Auto-stash before reset: $(date +%Y-%m-%d)"
- •Switch to main:
git checkout main - •Pull latest:
git pull origin main - •Install dependencies:
npm i(ifpackage.jsonexists)
Track which repos had stashes created.
Output Summary
After processing, provide summary:
markdown
## Reset Complete | Repo | Stashed? | Stash Summary | |------|----------|---------------| | repo1 | Yes | 2 modified files: src/index.ts, package.json | | repo2 | No | - | | repo3 | Yes | 1 new file: test/draft.ts |
For stashed repos, include:
- •Number of files affected
- •Key file names (truncate if many)
- •Type of changes (modified, new, deleted)
Recovering Stashed Changes
bash
# View stashes git stash list # Apply most recent stash (keeps stash) git stash apply # Apply and remove stash git stash pop