In this lesson, you will learn how to create a personal server-side copy of an external project to establish a dedicated workspace for your proposed code changes.
Understanding the Fork
When you want to contribute to a repository you do not own—such as an open-source project—you lack the permissions to push your branches directly to their remote. A "fork" solves this by creating a server-side clone of that repository under your own GitHub account.
Think of a fork as a "personal mirror" of the original project. You own this copy entirely, meaning you have full push access to it. This allows you to develop, push, and experiment without affecting the original project's history until you are ready to propose your changes.
Establishing Your Workspace
To create a fork, navigate to the target repository on GitHub and click the Fork button in the top-right corner. GitHub will then copy the entire project, including all branches and history, into your account as your-username/original-project.
Once the fork exists, you can treat it like any other remote repository you’ve worked with:
# Clone your personal fork to your local machine
git clone https://github.com/your-username/original-project.git
# Set your local copy to track your fork
git remote add origin https://github.com/your-username/original-project.git
# Establish the original project as 'upstream' to pull updates
git remote add upstream https://github.com/original-owner/original-project.git
By configuring these two remotes, you maintain a clean workflow: you push your completed feature branches to origin (your fork) so you can open Pull Requests to the original project, while periodically pulling updates from upstream to ensure your work remains compatible with the latest changes from the maintainers.
This separation of concerns ensures that you remain an independent contributor, keeping your experiments isolated within your fork until your code is ready for the main repository's review process.
Key Takeaway: A fork provides you with a personal remote repository where you have full control, allowing you to develop independently and propose changes to projects you do not own.