Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Fork and Clone a Repository | Getting Started with Open Source
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Git for Open Source Contributors

bookFork 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
copy

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.

question mark

Which of the following best describes the purpose of forking a repository in open source contribution?

Select the correct answer

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 1. ChapterΒ 1

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

Suggested prompts:

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?

bookFork 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
copy

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.

question mark

Which of the following best describes the purpose of forking a repository in open source contribution?

Select the correct answer

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 1. ChapterΒ 1
some-alt