Git Workflow
Committing Work
bash1cd ~/Code/community-patterns 2 3git add patterns/$GITHUB_USER/pattern.tsx 4git commit -m "Add pattern: description" 5git push origin main
Getting Updates (Already done in Step 1)
bash1git fetch upstream 2git pull --rebase upstream main 3git push origin main
Sharing Work Upstream (Creating Pull Requests)
IMPORTANT: Wait for user to tell you to create a PR. Don't push or create PRs automatically.
Before creating any PR, you MUST update from main and rebase your branch:
Step 0: Update and Rebase Before Creating PR
Use cached repository type from workspace config:
bash1# Read IS_FORK from .claude-workspace (set during Step 2) 2IS_FORK=$(grep "^is_fork=" .claude-workspace | cut -d= -f2) 3 4# Determine which remote to use 5if [ "$IS_FORK" = "true" ]; then 6 echo "Working on fork - will fetch from upstream" 7 MAIN_REMOTE="upstream" 8else 9 echo "Working on main repo - will fetch from origin" 10 MAIN_REMOTE="origin" 11fi
Then fetch latest main and rebase your branch:
bash1# Fetch latest main 2git fetch $MAIN_REMOTE 3 4# Rebase current branch on top of main 5git rebase $MAIN_REMOTE/main 6 7# If rebase succeeds, push (force-with-lease if on feature branch) 8if [ "$(git branch --show-current)" != "main" ]; then 9 git push origin $(git branch --show-current) --force-with-lease 10else 11 git push origin main 12fi
If rebase has conflicts:
- Show conflict files:
git status - Help resolve conflicts
- Continue:
git rebase --continue - Then push
Why this matters:
- Ensures your PR is based on the latest main
- Avoids merge conflicts during PR review
- Makes PR review easier
If User Has Their Own Fork (Most Common)
When user wants to contribute patterns from their fork to upstream:
Step 1: Ensure changes are committed and pushed to their fork
bash1cd ~/Code/community-patterns 2git status # Verify all changes are committed 3git push origin main
Step 2: Update and rebase (see Step 0 above)
Step 3: Create pull request to upstream
bash1gh pr create \ 2 --repo jkomoros/community-patterns \ 3 --title "Add: pattern name" \ 4 --body "$(cat <<'EOF' 5## Summary 6- Brief description of the pattern 7- Key features 8- Use cases 9 10## Testing 11- [x] Pattern compiles without errors 12- [x] Tested in browser at http://localhost:8000 13- [x] All features working as expected 14 15🤖 Generated with [Claude Code](https://claude.com/claude-code) 16EOF 17)"
If Working Directly on jkomoros/community-patterns
CRITICAL: When working directly on the upstream repository, you MUST use branches and PRs. Direct pushes to main are NOT allowed.
Step 1: Create feature branch
bash1cd ~/Code/community-patterns 2git checkout -b username/feature-name
Step 2: Commit and push branch
bash1git add patterns/$GITHUB_USER/ 2git commit -m "Add: pattern name" 3git push origin username/feature-name
Step 3: Update and rebase (see Step 0 above)
Step 4: Create pull request
bash1gh pr create \ 2 --title "Add: pattern name" \ 3 --body "$(cat <<'EOF' 4## Summary 5- Brief description 6 7## Testing 8- [x] Tested and working 9 10🤖 Generated with [Claude Code](https://claude.com/claude-code) 11EOF 12)"
Step 5: Merge with rebase (when approved)
bash1gh pr merge PR_NUMBER --rebase --delete-branch
Important Notes
- Always wait for user permission before creating PRs
- All PRs are merged with
--rebase(NOT--squashor--merge) - This preserves individual commit history
- Commit frequently locally, but only create PR when user asks
- PRs will be reviewed before merging to upstream
- After merge, everyone gets your patterns automatically on next update