Lesson 3
Cloning and Forking Repositories
In this lesson, we will explore the concepts of cloning and forking repositories, and how they can be used to collaborate on projects, contribute to open-source software, and manage your own copies of repositories.
Objectives
- Understand the difference between cloning and forking repositories
- Learn how to clone a repository
- Learn how to fork a repository
- Understand the use cases for cloning and forking
Cloning a repository
Cloning a repository creates a local copy of a remote repository on your computer. This allows you to work on the project, make changes, and commit them without affecting the original repository. To clone a repository, use the git clone
command followed by the repository URL.
Forking a repository
Forking a repository creates a copy of the repository under your GitHub account. This allows you to make changes to the project and submit pull requests to contribute to the original repository. To fork a repository, click the "Fork" button on the top right corner of the repository page on GitHub.
Comparing cloning and forking
While both cloning and forking create copies of a repository, they serve different purposes. Cloning is used to create a local copy of a repository to work on, while forking is used to create a copy under your GitHub account to contribute to the original project. Forking also allows you to create pull requests, which are essential for contributing to open-source projects.
Exercises
Fork, clone, edit, add, commit, and push
- Fork the repository https://github.com/eriknewland/lesson1-repo by clicking the "Fork" button on the top right corner of the repository page.
- Clone the forked repository to your local machine using the
git clone
command followed by the repository URL. - Open the README file and fix the typo on line 5.
- Use
git add
to stage the changes you made to the README file. - Commit the changes using
git commit -m "Fix typo in README"
. - Push the changes to your forked repository using
git push
. Note: In this exercise, we will not create a pull request.