Fork & Pull Request Guide
Complete step-by-step guide for contributing to Data Helpers via fork and pull request workflow.
Introduction
Section titled “Introduction”This guide covers the complete workflow:
- Fork - Create your own copy of the repository
- Clone - Download your fork to your local machine
- Work - Make changes and commit them
- Push - Upload your changes to your fork
- Pull Request - Request to merge your changes into the original repository
- Sync - Keep your fork up-to-date with the original repository
Step 1: Fork the Repository
Section titled “Step 1: Fork the Repository”What is a Fork?
Section titled “What is a Fork?”A fork is your personal copy of the repository on GitHub. You have full control over your fork and can make any changes without affecting the original repository.
How to Fork
Section titled “How to Fork”-
Go to the repository:
https://github.com/event4u-app/data-helpers -
Click the “Fork” button in the top-right corner
-
Select your account as the destination
-
Wait for GitHub to create your fork
- GitHub will redirect you to your fork:
https://github.com/YOUR_USERNAME/data-helpers
- GitHub will redirect you to your fork:
✅ Done! You now have your own copy of the repository.
Step 2: Clone Your Fork
Section titled “Step 2: Clone Your Fork”Clone to Your Local Machine
Section titled “Clone to Your Local Machine”# Clone your fork (replace YOUR_USERNAME with your GitHub username)git clone git@github.com:YOUR_USERNAME/data-helpers.git
# Navigate into the directorycd data-helpersVerify the Remote
Section titled “Verify the Remote”# Check the remote URLgit remote -vOutput:
origin git@github.com:YOUR_USERNAME/data-helpers.git (fetch)origin git@github.com:YOUR_USERNAME/data-helpers.git (push)✅ Done! Your fork is now on your local machine.
Step 3: Add Upstream Remote
Section titled “Step 3: Add Upstream Remote”What is Upstream?
Section titled “What is Upstream?”The “upstream” remote points to the original repository. This allows you to pull updates from the original repository into your fork.
Add Upstream Remote
Section titled “Add Upstream Remote”# Add the original repository as "upstream"git remote add upstream git@github.com:event4u-app/data-helpers.git
# Verify both remotesgit remote -vOutput:
origin git@github.com:YOUR_USERNAME/data-helpers.git (fetch)origin git@github.com:YOUR_USERNAME/data-helpers.git (push)upstream git@github.com:event4u-app/data-helpers.git (fetch)upstream git@github.com:event4u-app/data-helpers.git (push)✅ Done! You can now pull updates from the original repository.
Step 4: Setup Development Environment
Section titled “Step 4: Setup Development Environment”Install Dependencies
Section titled “Install Dependencies”# Install Composer dependenciescomposer install
# Or using Task (if Docker is available)task installStart Docker Containers (Optional)
Section titled “Start Docker Containers (Optional)”# Start Docker containerstask docker:up
# Verify containers are runningtask docker:psRun Tests
Section titled “Run Tests”# Run tests to ensure everything workstask test:run
# Or without Dockervendor/bin/pest✅ Done! Your development environment is ready.
Step 5: Create a Feature Branch
Section titled “Step 5: Create a Feature Branch”Why a Feature Branch?
Section titled “Why a Feature Branch?”Always create a new branch for your changes. This keeps your main branch clean and makes it easier to work on multiple features simultaneously.
Create and Switch to a New Branch
Section titled “Create and Switch to a New Branch”# Create and switch to a new branchgit checkout -b feature/my-awesome-feature
# Or for bug fixesgit checkout -b fix/bug-descriptionBranch naming conventions:
feature/- New featuresfix/- Bug fixesdocs/- Documentation changesrefactor/- Code refactoringtest/- Test additions or changes
✅ Done! You’re now on your feature branch.
Step 6: Make Your Changes
Section titled “Step 6: Make Your Changes”Edit Files
Section titled “Edit Files”Make your changes using your favorite editor:
# Example: Edit a filevim src/DataMapper/DataMapper.php
# Or open in your IDEcode .Check Your Changes
Section titled “Check Your Changes”# See which files you've changedgit status
# See the actual changesgit diffRun Quality Checks
Section titled “Run Quality Checks”# Fix code styletask quality:ecs:fix
# Run PHPStantask quality:phpstan
# Run teststask test:run✅ Done! Your changes are ready to commit.
Step 7: Commit Your Changes
Section titled “Step 7: Commit Your Changes”Stage Your Changes
Section titled “Stage Your Changes”# Stage all changesgit add .
# Or stage specific filesgit add src/DataMapper/DataMapper.phpgit add tests/Unit/DataMapper/DataMapperTest.phpCommit with a Good Message
Section titled “Commit with a Good Message”# Commit with a descriptive messagegit commit -m "feat: add support for nested wildcard mapping"Commit message format (Conventional Commits):
feat:- New featurefix:- Bug fixdocs:- Documentation changesstyle:- Code style changes (formatting)refactor:- Code refactoringtest:- Test changeschore:- Build/tooling changes
Examples:
git commit -m "feat: add support for nested wildcard mapping"git commit -m "fix: resolve issue with null values in DataAccessor"git commit -m "docs: update DataMapper examples"git commit -m "test: add tests for wildcard iteration"✅ Done! Your changes are committed locally.
Step 8: Push to Your Fork
Section titled “Step 8: Push to Your Fork”Push Your Branch
Section titled “Push Your Branch”# Push your branch to your forkgit push origin feature/my-awesome-featureFirst time pushing this branch? Git will show:
To github.com:YOUR_USERNAME/data-helpers.git * [new branch] feature/my-awesome-feature -> feature/my-awesome-featurePush Subsequent Changes
Section titled “Push Subsequent Changes”# Make more changesgit add .git commit -m "feat: improve error handling"
# Push againgit push origin feature/my-awesome-feature✅ Done! Your changes are now on GitHub in your fork.
Step 9: Create a Pull Request
Section titled “Step 9: Create a Pull Request”Open Pull Request on GitHub
Section titled “Open Pull Request on GitHub”-
Go to your fork on GitHub:
https://github.com/YOUR_USERNAME/data-helpers -
GitHub will show a banner:
feature/my-awesome-feature had recent pushes[Compare & pull request] -
Click “Compare & pull request”
-
Fill in the PR details:
- Title: Clear, descriptive title (e.g., “Add support for nested wildcard mapping”)
- Description: Explain what you changed and why
- Reference issues: If fixing an issue, mention it (e.g., “Fixes #123”)
-
Click “Create pull request”
PR Description Template
Section titled “PR Description Template”## DescriptionBrief description of what this PR does.
## Changes- Added feature X- Fixed bug Y- Updated documentation Z
## Testing- [ ] All tests pass- [ ] Added new tests for new features- [ ] Manually tested the changes
## Related IssuesFixes #123✅ Done! Your pull request is created and ready for review.
Step 10: Respond to Review Feedback
Section titled “Step 10: Respond to Review Feedback”Make Requested Changes
Section titled “Make Requested Changes”# Make the requested changesvim src/DataMapper/DataMapper.php
# Commit the changesgit add .git commit -m "fix: address review feedback"
# Push to your branchgit push origin feature/my-awesome-featureThe PR will automatically update with your new commits!
Squash Commits (Optional)
Section titled “Squash Commits (Optional)”If you have many small commits, you might want to squash them:
# Interactive rebase (last 3 commits)git rebase -i HEAD~3
# In the editor, change "pick" to "squash" for commits you want to combine# Save and exit
# Force push (only do this on your own branch!)git push origin feature/my-awesome-feature --force✅ Done! Your PR is updated with the requested changes.
Step 11: Keep Your Fork Up-to-Date
Section titled “Step 11: Keep Your Fork Up-to-Date”Why Sync Your Fork?
Section titled “Why Sync Your Fork?”The original repository receives updates from other contributors. You need to sync your fork to stay up-to-date.
Sync Your Fork
Section titled “Sync Your Fork”# Switch to main branchgit checkout main
# Fetch updates from upstreamgit fetch upstream
# Merge upstream changes into your main branchgit merge upstream/main
# Push updates to your forkgit push origin mainUpdate Your Feature Branch
Section titled “Update Your Feature Branch”# Switch to your feature branchgit checkout feature/my-awesome-feature
# Merge main into your feature branchgit merge main
# Or rebase (cleaner history)git rebase main
# Push updatesgit push origin feature/my-awesome-feature✅ Done! Your fork is up-to-date with the original repository.
Common Workflows
Section titled “Common Workflows”Starting a New Feature
Section titled “Starting a New Feature”# 1. Update your main branchgit checkout maingit fetch upstreamgit merge upstream/maingit push origin main
# 2. Create a new feature branchgit checkout -b feature/new-feature
# 3. Make changes, commit, and pushgit add .git commit -m "feat: add new feature"git push origin feature/new-feature
# 4. Create PR on GitHubFixing a Bug
Section titled “Fixing a Bug”# 1. Update your main branchgit checkout maingit fetch upstreamgit merge upstream/main
# 2. Create a fix branchgit checkout -b fix/bug-description
# 3. Fix the bug, add testsgit add .git commit -m "fix: resolve bug description"
# 4. Run teststask test:run
# 5. Push and create PRgit push origin fix/bug-descriptionUpdating an Existing PR
Section titled “Updating an Existing PR”# 1. Switch to your feature branchgit checkout feature/my-feature
# 2. Make changesgit add .git commit -m "fix: address review feedback"
# 3. Push (PR updates automatically)git push origin feature/my-featureTroubleshooting
Section titled “Troubleshooting”Merge Conflicts
Section titled “Merge Conflicts”If you get merge conflicts when syncing:
# 1. Try to mergegit merge upstream/main
# 2. Git will show conflicts# CONFLICT (content): Merge conflict in src/DataMapper/DataMapper.php
# 3. Open the file and resolve conflictsvim src/DataMapper/DataMapper.php
# 4. Look for conflict markers<<<<<<< HEADYour changes=======Upstream changes>>>>>>> upstream/main
# 5. Edit the file to keep the correct code
# 6. Stage the resolved filegit add src/DataMapper/DataMapper.php
# 7. Complete the mergegit commit
# 8. Pushgit push origin mainAccidentally Committed to Main
Section titled “Accidentally Committed to Main”# 1. Create a new branch from current stategit checkout -b feature/my-feature
# 2. Push the new branchgit push origin feature/my-feature
# 3. Reset main to upstreamgit checkout maingit reset --hard upstream/maingit push origin main --forceNeed to Undo Last Commit
Section titled “Need to Undo Last Commit”# Undo last commit but keep changesgit reset --soft HEAD~1
# Undo last commit and discard changesgit reset --hard HEAD~1Summary
Section titled “Summary”Complete workflow:
- ✅ Fork the repository on GitHub
- ✅ Clone your fork locally
- ✅ Add upstream remote
- ✅ Create a feature branch
- ✅ Make changes and commit
- ✅ Push to your fork
- ✅ Create a pull request
- ✅ Respond to feedback
- ✅ Keep your fork synced
Next Steps
Section titled “Next Steps”- Contributing Guide - Learn about code style and testing
- Development Setup - Setup your development environment
- Test Matrix - Learn about testing