Fork and Clone a Repository
When you want to contribute to an open source project, you typically do not have direct write access to the original repository. Instead, you use the fork and clone workflow. This process allows you to create your own copy of the project, make changes safely, and propose those changes for inclusion in the original project. This workflow is important because it keeps the original repository secure while enabling anyone to contribute improvements. By forking and cloning, you can experiment freely, work independently, and submit your contributions through pull requests.
123456789101112131415# Step 1: Fork the repository on GitHub # - Go to the project's GitHub page (for example: https://github.com/ORIGINAL_OWNER/REPO_NAME) # - Click the "Fork" button in the upper right corner # Step 2: Clone your forked repository to your local machine git clone https://github.com/YOUR_GITHUB_USERNAME/REPO_NAME.git # Step 3: Change directory to the cloned repository cd REPO_NAME # Step 4: Add the original repository as the "upstream" remote git remote add upstream https://github.com/ORIGINAL_OWNER/REPO_NAME.git # Step 5: Verify your remotes git remote -v
After you clone your fork, your local repository will have two remotes: origin and upstream. The origin remote points to your fork of the repository on your GitHub account. This is where you push your changes. The upstream remote points to the original repository that you forked from. You use upstream to fetch updates from the main project, so you can keep your fork in sync with the latest changes.
Thanks for your feedback!
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
Can you explain the difference between 'origin' and 'upstream' remotes?
How do I keep my fork up to date with the original repository?
What should I do after setting up the remotes?
Awesome!
Completion rate improved to 8.33
Fork and Clone a Repository
Swipe to show menu
When you want to contribute to an open source project, you typically do not have direct write access to the original repository. Instead, you use the fork and clone workflow. This process allows you to create your own copy of the project, make changes safely, and propose those changes for inclusion in the original project. This workflow is important because it keeps the original repository secure while enabling anyone to contribute improvements. By forking and cloning, you can experiment freely, work independently, and submit your contributions through pull requests.
123456789101112131415# Step 1: Fork the repository on GitHub # - Go to the project's GitHub page (for example: https://github.com/ORIGINAL_OWNER/REPO_NAME) # - Click the "Fork" button in the upper right corner # Step 2: Clone your forked repository to your local machine git clone https://github.com/YOUR_GITHUB_USERNAME/REPO_NAME.git # Step 3: Change directory to the cloned repository cd REPO_NAME # Step 4: Add the original repository as the "upstream" remote git remote add upstream https://github.com/ORIGINAL_OWNER/REPO_NAME.git # Step 5: Verify your remotes git remote -v
After you clone your fork, your local repository will have two remotes: origin and upstream. The origin remote points to your fork of the repository on your GitHub account. This is where you push your changes. The upstream remote points to the original repository that you forked from. You use upstream to fetch updates from the main project, so you can keep your fork in sync with the latest changes.
Thanks for your feedback!