Git Workflow
Overview
Our team follows a structured Git workflow to ensure code quality, maintainability, and collaboration. This document outlines our agreed-upon Git practices and conventions.
Branch Structure
Main Branches
- main: Production-ready code, always deployable. Developers do not work directly on this branch. Changes from staging are automatically deployed to main via Laravel Forge at scheduled times.
- staging: Pre-production testing environment. Hotfixes are branched from and merged back to this branch.
- develop: Integration branch for features. Regular development work is branched from and merged back to this branch.
Branch Workflow
- Regular Development: Developers create branches from
developand push changes back todevelopvia pull requests. - Hotfixes: For critical issues, developers create branches from
stagingand push changes back tostagingvia pull requests. - Cherry-picking: The CTO is responsible for cherry-picking changes between
staginganddevelopbranches to keep them in sync.
Supporting Branches
- feature/[feature-name]: New features or enhancements
- fix/[bug-description]: Non-critical bug fixes
- hotfix/[hotfix-description]: Critical production fixes
- change/[description]: Changes to existing functionality
- improvement/[description]: Improvements to existing features
- update/[description]: Updates to dependencies or configurations
- SDK/[description]: SDK-related changes
Branch Naming Conventions
Branch names that do not follow these conventions will result in immediate closure of pull requests.
Branch names must consist of two parts separated by a forward slash:
- Type: Indicates the type of work being done
- Description: Describes the actual work
(hotfix|fix|change|feature|improvement|SDK|update)/what-we-do
The description part must follow slug conventions (lowercase with hyphens for word separation).
Valid Examples:
hotfix/mass-notiffeature/user-authenticationfix/login-validationchange/payment-flowimprovement/dashboard-performanceSDK/client-updateupdate/dependencies
Invalid Examples:
bug/login-issue(incorrect type)feature_user_auth(incorrect separator)hotfix/Mass-Notification(incorrect casing)
Commit Guidelines
Commit Message Format
We follow a structured commit message format:
[type]: Short summary (50 chars or less)
Detailed explanation if necessary. Wrap at 72 characters.
Explain what and why, not how (the code shows that).
Fixes #123
Commit Types
- feat: New feature
- fix: Bug fix
- docs: Documentation changes
- style: Formatting changes (white-space, formatting, etc.)
- refactor: Code change that neither fixes a bug nor adds a feature
- test: Adding or updating tests
- chore: Changes to build process or auxiliary tools
- perf: Performance improvements
Commit Best Practices
- Make atomic commits (one logical change per commit)
- Write descriptive commit messages
- Reference issue numbers in commit messages
- Don't commit commented-out code
- Don't commit debug code or console logs
- Don't commit generated files or dependencies
Code Quality Checks Before Committing
Before submitting code for review, all developers must run linters and formatters on their code.
Run the following command to check your latest commit:
php artisan code:run-all lastcommit
This command will:
- Run all linters on your code
- Format your code according to project standards
- Check for common issues and coding standard violations
If the command reports any issues, fix them before creating a pull request. Pull requests with linting or formatting issues will be rejected.
Pull Request Process
- Creating PRs
- PR Reviews
- Merging
Creating Pull Requests
- Create a branch from the appropriate base branch (develop for regular work, staging for hotfixes)
- Make your changes in small, logical commits
- Run linters and formatters (
php artisan code:run-all lastcommit) - Push your branch to the remote repository
- Create a pull request with a descriptive title and description
- Fill out the PR template completely
- Assign reviewers (minimum 2, including CTO)
- Link related issues
PR Description Requirements
Pull requests that do not follow these description guidelines will not be merged.
PR descriptions must be comprehensive and self-contained:
- Do not reference tasks, Sentry, or Telescope in lieu of proper descriptions
- Write complete explanations of what changes were made and why
- For package updates (especially client-side SDK updates), explicitly list all changes in the new version
Required PR Description Structure
Pull requests that do not follow this exact structure will be closed immediately. You will need to create a new PR with the correct structure.
All pull request descriptions must follow this exact structure:
Related Task: (Trello task URL)
Description: (Clear explanation of what changes were made)
Test Checklist:
- First item
- Second item
- Third item
In the test checklist, include items that:
- Need to be tested after this PR is merged
- Are directly related to the task
- May be affected by side effects of your changes
PR Template
## Related Task
[Insert Trello task URL here]
## Description
[Explain what changes you've made - clearly and in detail]
## Test Checklist
- [First item that needs testing]
- [Second item that needs testing]
- [Third item that needs testing]
## Package Updates (if applicable)
- [Package Name] updated from [old version] to [new version]
- Changes in this version:
- [List all significant changes in the new version]
- [Include any breaking changes]
## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Breaking change
- [ ] Documentation update
## How Has This Been Tested?
[Describe the testing approach]
## Checklist
- [ ] My code follows the project's coding standards
- [ ] I have added tests that prove my fix/feature works
- [ ] I have updated documentation as needed
- [ ] All tests pass locally
Pull Request Reviews
- Reviewers should review the code within 24 hours
- Check for:
- Code quality and adherence to coding standards
- Test coverage
- Documentation updates
- Security considerations
- Performance implications
- Provide constructive feedback
- Approve only when all issues are addressed
- Final approval must come from CTO
Never manually resolve any code review comments. Only the CTO may manually resolve comments if necessary.
See our Code Review Guidelines for more details.
Merging Pull Requests
- Ensure all CI checks pass
- Require minimum 2 approvals (including CTO)
- Resolve all conversations
- Ensure no unrelated commits or files are included in the PR
Pull requests containing unrelated commits or files will not be merged. It is the developer's responsibility to clean up their PR using rebase or merge techniques.
- Use "Squash and merge" for feature branches
- Use "Merge commit" for hotfix branches
- Delete the branch after merging
Merge Commit Message
When squashing, ensure the commit message follows our format:
[type]: Summary of changes (#PR_NUMBER)
- Detail 1
- Detail 2
- Detail 3
Fixes #ISSUE_NUMBER
Handling Conflicts and Unrelated Changes
Pull requests containing unrelated commits or files from other developers will not be merged.
When your branch contains unrelated changes:
- It is your responsibility to clean up your branch
- You may use rebase or merge techniques as you prefer
- The CTO will not assist with resolving these issues
- The problem must be 100% resolved before the PR will be merged
Recommended Approach for Cleaning Branches
# Option 1: Using rebase to clean up your branch
git checkout develop # or staging for hotfixes
git pull
git checkout your-branch
git rebase -i develop # or staging for hotfixes
# In the interactive rebase, keep only your commits and drop others
# Option 2: Creating a clean branch
git checkout develop # or staging for hotfixes
git pull
git checkout -b clean-branch-name
git cherry-pick <your-commit-hashes>
# Then create a new PR from the clean branch
Handling Conflicts
When conflicts arise:
- Pull the latest changes from the base branch (develop or staging)
- Resolve conflicts locally
- Test thoroughly after conflict resolution
- Push the resolved changes
- Document complex conflict resolutions in the PR
Release Process
Our Git release process:
- Changes are merged into the develop branch through the PR process
- The staging branch is updated with changes from develop (managed by CTO)
- Testing is performed on the staging environment
- At scheduled times, changes from staging are automatically deployed to main via Laravel Forge
- For hotfixes, changes are merged directly to staging and then cherry-picked to develop by the CTO
Git Hooks
We use Git hooks to enforce quality:
- pre-commit: Run linting and formatting
- pre-push: Run tests
- commit-msg: Validate commit message format
Continuous Integration
Our CI pipeline runs on all pull requests:
- Build the project
- Run linting and static analysis
- Run unit and integration tests
- Generate code coverage reports
- Check for security vulnerabilities
- Build documentation
Git Best Practices
- Keep branches short-lived (1-2 weeks maximum)
- Pull from the base branch regularly to minimize conflicts
- Don't force push to shared branches
- Use rebase to keep feature branches up-to-date
- Write meaningful commit messages
- Commit early and often
- Review your own code before requesting reviews
Git Configuration
Recommended Git configuration:
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
git config --global core.editor "code --wait"
git config --global pull.rebase true
git config --global rebase.autoStash true
Troubleshooting Common Issues
Resolving Merge Conflicts
# Update your branch with the latest changes
git checkout develop # or staging for hotfixes
git pull
git checkout your-branch
git rebase develop # or staging for hotfixes
# Resolve conflicts and continue
git add .
git rebase --continue
Undoing Local Changes
# Discard all local changes
git reset --hard HEAD
# Discard changes to a specific file
git checkout -- path/to/file
# Undo the last commit but keep changes
git reset --soft HEAD~1