PR Workflow Guide

Master the Git branching and pull request process

← Back to Hub

🚀 The PR Lifecycle

🌱
Create Branch
💾
Make Commits
📤
Push to Remote
📄
Open PR
🔎
Code Review
Merge

🌱 Step 1: Create a Feature Branch

Always work on a separate branch, never directly on main/master.

# Make sure you're on main and up-to-date
$ git checkout main
$ git pull origin main

# Create and switch to new branch
$ git checkout -b feature/add-hpo-config

Branch Naming Conventions

  • feature/ - New functionality (feature/add-optuna-hpo)
  • fix/ - Bug fixes (fix/reward-calculation)
  • experiment/ - Experimental changes (experiment/new-architecture)
  • docs/ - Documentation updates (docs/update-readme)

💾 Step 2: Make Commits

Make small, focused commits with clear messages.

# Stage specific files
$ git add configs/hpo_config.yaml
$ git add src/hpo_runner.py

# Or stage all changes
$ git add .

# Commit with a descriptive message
$ git commit -m "Add Optuna HPO configuration and runner script"

Good Commit Messages

✅ Do
  • "Add learning rate to search space"
  • "Fix reward calculation bug"
  • "Update README with setup instructions"
❌ Don't
  • "fix stuff"
  • "WIP"
  • "asdfasdf"

📤 Step 3: Push to Remote

Push your branch to GitHub to share with teammates.

# First push: set upstream
$ git push -u origin feature/add-hpo-config

# Subsequent pushes
$ git push

Before Pushing

  • Code runs without errors
  • Tests pass (if applicable)
  • No sensitive data (API keys, passwords)
  • No large files (models, data)

📄 Step 4: Open a Pull Request

Create a PR on GitHub to request merging your changes.

# Using GitHub CLI
$ gh pr create --title "Add Optuna HPO configuration" --body "..."

# Or go to GitHub and click "New Pull Request"

PR Description Template

## Summary Brief description of what this PR does. ## Changes - Added HPO configuration file - Implemented Optuna objective function - Updated README with HPO instructions ## Testing - [ ] Ran HPO with 5 trials locally - [ ] Verified results export to CSV - [ ] Checked TensorBoard logging ## Screenshots (if applicable) [Add any relevant screenshots]

🔎 Step 5: Code Review

Reviewers examine your code and provide feedback.

Review Types

Approve
Ready to merge
🛠
Request Changes
Needs modifications
💬
Comment
Questions or notes

Responding to Feedback

  • Address all comments before requesting re-review
  • Make new commits to address changes (don't force push)
  • Reply to comments explaining your changes
  • Be open to suggestions - reviewers help improve code quality

✅ Step 6: Merge

Once approved, merge your PR into main.

# On GitHub: Click "Merge pull request"
# Or using CLI:
$ gh pr merge --squash

Merge Strategies

  • Squash and merge - Combines all commits into one (recommended for feature branches)
  • Merge commit - Keeps all commits with a merge commit
  • Rebase and merge - Replays commits on top of main

After Merging

# Update your local main
$ git checkout main
$ git pull origin main

# Delete the feature branch (optional)
$ git branch -d feature/add-hpo-config

💡 PR Best Practices

  • Keep PRs small and focused
  • One feature/fix per PR
  • Write descriptive titles
  • Include context in description
  • Request specific reviewers

🔎 Review Best Practices

  • Be constructive, not critical
  • Explain the "why" behind suggestions
  • Praise good code too
  • Ask questions instead of demanding
  • Review promptly (within 24 hours)

🚧 Common Pitfalls

  • Committing directly to main
  • Giant PRs (500+ lines)
  • Ignoring review feedback
  • Not testing before pushing
  • Merging without approval

📋 Quick Reference Commands

# Check current branch $ git branch # See status of changes $ git status # View commit history $ git log --oneline -10 # Discard local changes $ git checkout -- filename.py # Stash changes temporarily $ git stash $ git stash pop # View diff of changes $ git diff