Collaborate with Forks
Forking is how you contribute to open‑source projects or collaborate on repositories where you don’t have write access. It creates a personal copy of someone else’s repository under your GitHub account.
What is a Fork?
A fork is a copy of a repository that lives in your own GitHub account. You can freely experiment and make changes without affecting the original project. When you’re ready to share your changes, you open a pull request.
Forking vs. Cloning
- Clone: Creates a local copy on your machine. It’s for working with a repository you have access to.
- Fork: Creates a server‑side copy under your account. It’s the starting point for contributing to projects you don’t own.
Typical Forking Workflow
1. Fork the repository on GitHub: click the "Fork" button on the original repo.
2. Clone your fork to your local machine:
git clone https://github.com/your-username/repo.git3. Add the original repository as upstream:
git remote add upstream https://github.com/original-owner/repo.git4. Create a branch for your changes.5. Make changes, commit, and push to your fork.
6. Open a pull request on GitHub from your branch to the original repository.
Keeping Your Fork Updated
While you work, the original repository may receive new commits. To keep your fork in sync:
git fetch upstream
git checkout main
git merge upstream/main
git push origin mainPull Requests
A pull request is a way to propose changes from your fork to the original repository. The project maintainers can review, discuss, and merge your changes. It’s the standard collaboration tool on GitHub, GitLab, and Bitbucket.
Two Minute Drill
- A fork is a personal copy of someone else’s repository on GitHub.
- Clone your fork locally, then add the original repo as
upstream. - Work on a branch, push to your fork, then open a pull request.
- Sync your fork by fetching and merging from upstream.
Need more clarification?
Drop us an email at career@quipoinfotech.com
