Forking & Contributing to Open Source
One of GitHub’s most powerful features is its ability to let you contribute to other people’s projects, even if you’re not part of the original team. The process starts with something called a fork.
What is a Fork?
A fork is your personal copy of someone else’s repository on GitHub. It allows you to:
- Experiment freely without affecting the original code
- Propose changes to someone else’s project via pull requests
✅ You can fork any public repo and start contributing right away.
Why Fork Instead of Clone?
- Cloning is used for repos you own or collaborate on.
- Forking is used to contribute to someone else’s project when you don’t have write access.
How to Fork a Repository
- Go to a public GitHub repository, e.g.,
https://github.com/twbs/bootstrap - Click the Fork button (top right).
- GitHub will copy the repo into your own account.
Now you have your own version where you can make changes.
💻 Clone Your Fork to Local Machine
Bash
git clone https://github.com/yourusername/bootstrap.git
cd bootstrap
Create a Feature Branch
Always create a new branch before editing:
Bash
git checkout -b fix-navbar-bug
Make your changes in code, then:
Bash
git add .
git commit -m "Fix: responsive navbar issue"
Push Your Changes to GitHub
Bash
git push origin fix-navbar-bug
Now your branch is on your GitHub fork.
🔁 Open a Pull Request (PR)
- Visit your forked repo on GitHub.
- GitHub will show: “Compare & pull request”
- Click it, write a message describing your changes, and submit.
The project maintainer will review and either:
- Approve and merge your changes
- Ask for modifications
- Close the request with feedback
✅ Best Practices for Contributions
- Write clear, descriptive commit messages.
- Follow the project’s contribution guidelines (usually in a
CONTRIBUTING.md
file). - Be respectful and professional in pull request comments.
🎉 Your First Contribution!
Once merged, your GitHub profile will show the contribution — and you’ve officially contributed to open source!
🔁 Summary: Forking Workflow
- Fork the repository
- Clone your fork locally
- Create a new branch
- Make changes and commit
- Push to your fork
- Open a pull request to the original repo