Skip to main content
WooCommerce follows a structured Git workflow to maintain code quality and enable efficient collaboration. This guide covers branching strategies, commit conventions, pull request requirements, and changelog management.

Repository Structure

WooCommerce is organized as a monorepo containing multiple packages and plugins:
Changes to any package require a changelog entry for that specific package before creating a PR.

Branching Strategy

WooCommerce uses a trunk-based development workflow:

Branch Types

  • Main development branch
  • All PRs target trunk by default
  • Always in a releasable state
  • Automatically deployed to staging

Creating a Feature Branch

1

Fork the Repository

Fork WooCommerce to your GitHub account via the repository page.
2

Clone Your Fork

3

Add Upstream Remote

4

Create Feature Branch

Branch Naming Conventions

Use descriptive prefixes for branch names:
  • add/ - New features
  • update/ - Enhancements to existing features
  • fix/ - Bug fixes
  • dev/ - Development/infrastructure changes
  • tweak/ - Minor adjustments

Commit Guidelines

Write clear, meaningful commit messages that explain why changes were made, not just what changed.

Commit Message Format

Writing Good Commit Messages

Commit Message Best Practices

  • Use present tense (“Add feature” not “Added feature”)
  • Capitalize first letter of summary
  • No period at end of summary line
  • Reference issue numbers with Closes #123 or Fixes #456
  • Keep summary under 50 characters
  • Wrap body at 72 characters
  • Explain why, not just what

Linking to Issues

Reference issues and PRs in commit messages:

Changelog Management

NEVER create a PR without changelog entries. Each affected package requires its own changelog entry.

Creating Changelog Entries

Before creating a PR, add changelog entries for each modified package:
1

Run Changelog Command

2

Select Change Significance

3

Select Change Type

4

Write Changelog Message

5

Commit Changelog File

Changelog File Format

Changelog entries are created as YAML files:
changelog/fix-checkout-validation

Pull Request Workflow

Before Creating a PR

1

Ensure Tests Pass

2

Run Linting

3

Run PHPStan

4

Create Changelog Entries

5

Push Changes

Creating the Pull Request

1

Open GitHub PR

Navigate to your fork on GitHub and click “Compare & pull request”
2

Fill PR Template

Use the provided template from .github/PULL_REQUEST_TEMPLATE.md:
3

Set Milestone

Check the box to auto-assign milestone:
4

Add Labels

Add appropriate labels:
  • type: enhancement, type: fix, etc.
  • focus: area-name for specific features

Pull Request Template Sections

PR Review Process

1

Automated Checks

  • Linting (PHP, JavaScript)
  • PHPUnit tests
  • E2E tests
  • API tests
  • PHPStan analysis
2

Code Review

  • Core team reviews code
  • Requests changes if needed
  • Approves when ready
3

Address Feedback

4

Merge

  • PR is merged to trunk by maintainer
  • Branch is automatically deleted

Advanced Git Workflows

Keeping Your Branch Updated

Only use --force-with-lease on your own feature branches, never on shared branches or trunk.

Squashing Commits

Squash multiple commits before merging:

Cherry-Picking Changes

Apply specific commits to another branch:

Common Git Issues

Git Best Practices

Do’s

  • ✅ Keep commits focused and atomic
  • ✅ Write descriptive commit messages
  • ✅ Reference issues in commits and PRs
  • ✅ Create changelog entries before PRs
  • ✅ Rebase on trunk regularly
  • ✅ Test before pushing
  • ✅ Use meaningful branch names

Don’ts

  • ❌ Commit directly to trunk
  • ❌ Force push to shared branches
  • ❌ Create PRs without changelog entries
  • ❌ Commit without testing
  • ❌ Use vague commit messages
  • ❌ Include unrelated changes in commits
  • ❌ Commit sensitive data or credentials

GitHub CLI (gh)

Use GitHub CLI for efficient PR management:

Pre-commit Hooks

WooCommerce uses Husky for pre-commit hooks that automatically:
  • Run PHP syntax check (php -l)
  • Run PHP_CodeSniffer on staged files
  • Run ESLint on staged JavaScript files
  • Fix auto-fixable issues
.husky/pre-commit
Pre-commit hooks help catch issues before they reach CI, saving time and ensuring code quality.

Summary Checklist

Before creating a PR, ensure:
  • Created feature branch from latest trunk
  • Made focused, atomic commits with good messages
  • Added changelog entries for all affected packages
  • All tests pass locally
  • Linting passes (PHP and JavaScript)
  • PHPStan analysis passes
  • PR description follows template
  • Testing instructions are clear
  • Referenced related issues
  • Added screenshots for UI changes
  • Set appropriate milestone
  • Added relevant labels

Next Steps

Coding Standards

Review coding standards and linting requirements

Testing

Learn about testing requirements and commands