🛠️ How to Contribute: The Workflow
Your Step-by-Step Guide to Making Your First Pull Request
So you found a bug to fix or a feature to add. Awesome! But how do you actually get your code into their project?
This is the standard Fork & Pull Request Workflow used by almost every open-source project.
🏗️ Step 1: Fork the Repository
A Fork is your personal copy of someone else's repository. You can't write directly to their project (you don't have permission), so you write to your copy first.
- Go to the project page on GitHub (e.g.,
facebook/react). - Click the Fork button in the top-right corner.
- GitHub will create a copy under your account (e.g.,
your-username/react).
📥 Step 2: Clone Your Fork
Now, bring that code to your local machine.
# Don't clone the original! Clone YOUR fork.
git clone https://github.com/your-username/project-name.git
cd project-name
🌿 Step 3: Create a New Branch
Never work on the main or master branch. Always create a separate branch for your specific task.
# Standard naming: feature/feature-name or fix/bug-name
git checkout -b fix/typo-in-readme
✍️ Step 4: Make Your Changes
- Open the code in VS Code.
- Fix the bug or add the feature.
- Test your changes! (Run the project locally to make sure it works).
💾 Step 5: Commit and Push
Save your changes and send them up to your fork on GitHub.
git add .
git commit -m "Fix typo in documentation"
git push origin fix/typo-in-readme
🔀 Step 6: Open a Pull Request (PR)
- Go to your fork on GitHub.
- You will see a yellow banner: "Compare & pull request". Click it.
- Title: Be clear (e.g., "Fixed broken link in CONTRIBUTING.md").
- Description: Explain what you changed and why.
- Click Create Pull Request.
🎉 Congratulations! You just submitted a contribution!
⏳ Step 7: The Review Cycle (Wait & Iterate)
The maintainers will get a notification. Now, three things can happen:
- Merged! 🥳 (They accept your code).
- Changes Requested: They like the idea but want you to fix something (style, variable names, etc.).
- What to do: Make changes locally,
git add,git commit, andgit push. The PR updates automatically!
- What to do: Make changes locally,
- Closed: They decided not to merge it. (Don't feel bad, it happens to everyone).
🔄 Pro Tip: Keeping Your Fork Sync'd
While you were working, the original project might have moved forward. To keep your fork up to date:
# Add the 'upstream' (original) repository
git remote add upstream https://github.com/original-owner/project-name.git
# Pull the latest changes
git pull upstream main