GitHub Clone Repository
You can clone a git repository as simply as follows:
$ git clone <git-repository-url>
<git-repository-url> should be replaced by the link of the repository that you want to clone, like this:
$ git clone https://github.com/4GeeksAcademy/html-hello
Cloning a repository creates a local copy of the desired project/repository on your computer, which syncs between the two locations (Remote-Local).
In other words, cloning a repository means downloading a complete copy of it to your computer. And what does a complete copy mean? Well, it means that after cloning a repository, you will have the entire history of the repository on your computer.
So why clone a repository you may ask? Cloning a project has many benefits as:
- Browse the project's history, and see how it has evolved.
- See the changes that have occurred in the code.
- Know who has modified the code and when.
- Access the branches of the project and create your own.
- Start modifying the code, save the changes and add your work to the existing one.
And all this without the need to be connected to the internet. We will only need an internet connection when we want to "share" our work with someone else, or we want to upload our work to GitHub.

In the following section, we will dive in on more detailed examples of how to clone a github repository and also how to fork any github repository.
Steps to Clone a GitHub Repository (Using the terminal)
For this example, we will clone one of 4Geeks popular repositories, that is 4Geeks react-flask-hello. The steps to clone this repository are as follows:
- Determine or locate where you want to clone the desired repository
Locate the folder on your computer where you want to save the repository, or you can create a new one. Let’s say we want to save our repository in a folder called
my-first-cloned-repoas shown below.

- Open the terminal
You can use the Git Bash terminal or any IDE (Integrated Development Environment) or Code Editor terminal. With the terminal opened, input
cdand add/copy the directory/folder location/path. Since we want to save the repository in our foldermy-first-cloned-repo, let's copy the folder's pathC:\Users\rafam\Programming Projects\my-first-cloned-repoand paste it on the terminal, you can also drag and drop the folder on the terminal and press enter
rafam@LAPTOP-LLV85FV6 MINGW64 ~
$ cd 'C:\Users\rafam\Programming Projects\my-first-cloned-repo'
rafam@LAPTOP-LLV85FV6 MINGW64 ~/Programming Projects/my-first-cloned-repo
- Go to the 4Geeks react-flask-hello repository in GitHub. Once you are located in the Github repository, you need to click the Code button to display the clone options and then click the Copy button which is highlighted (shown below) and next to the repo URL:


- Go to the terminal and use the git clone command by typing
git clonealong with the copied URL
rafam@LAPTOP-LLV85FV6 MINGW64 ~
$ cd 'C:\Users\rafam\Programming Projects\my-first-cloned-repo'
rafam@LAPTOP-LLV85FV6 MINGW64 ~/Programming Projects/my-first-cloned-repo
$ git clone https://github.com/4GeeksAcademy/react-flask-hello.git
- Press Enter and the repository will be cloned
rafam@LAPTOP-LLV85FV6 MINGW64 ~
$ cd 'C:\Users\rafam\Programming Projects\my-first-cloned-repo'
rafam@LAPTOP-LLV85FV6 MINGW64 ~/Programming Projects/my-first-cloned-repo
$ git clone https://github.com/4GeeksAcademy/react-flask-hello.git
Cloning into 'react-flask-hello'...
remote: Enumerating objects: 1024, done.
remote: Counting objects: 100% (33/33), done.
remote: Compressing objects: 100% (22/22), done.
Receiving objects: 99% (1014/1024), 6.82 MiB | 6.79 MiB/seused 991
Receiving objects: 100% (1024/1024), 8.86 MiB | 7.31 MiB/s, done.
Resolving deltas: 100% (521/521), done.
It is important to understand that you can clone any repository not only from GitHub but from any other site if you have the git URL. Remember that you clone a repository with the git clone <url> command.
Clone vs Fork
The difference between forking and cloning a project/repository really comes down to how much control a developer is allowed to have over a given repository.
By Forking, you can make your own copy of a repository somewhere else (for example, GitHub). Owning a copy of the repository means that you can make changes to it without affecting the original repository.
Cloning creates a local copy of a repository. Imagine doing that by downloading a repository to your computer's local storage. Clones have references to their original repositories, unlike forks.

How to Fork a Repository
So you want to make your own copy of a repository, let's make a copy of the one that we cloned in the example above, 4Geeks react-flask-hello.
The steps to fork the repository are the following:
-
Go to the GitHub repository 4Geeks react-flask-hello
-
Click the Fork button located in the top right corner of the page

- Then, an owner must be selected for the forked repository by clicking the Select an owner button and choosing the Repository name. You can also add a description (optional) to your fork if desired.

- Below the description field, there is a checkbox (Copy the
mainbranch only) that allows you to only copy the main branch, if you want to copy the whole repository with all of its branches, then this box should be unmarked.

- You can now click Create Fork and it'll be done

How to clone using the GitHub app instead of the terminal
You can also use the GitHub Desktop App to clone a repository to your computer, once you have downloaded the GitHub Desktop App here, and being signed to the GitHub website and Desktop App, then you can follow these steps:
- Go to the desired GitHub repository, and let's use the 4Geeks react-flask-hello repo again. Click on the Code button to display the options and proceed to click the Open with GitHub Desktop button.

- The GitHub Desktop App will automatically open on your computer and a window called Clone a repository will be displayed. Here you can confirm the repository to be cloned, and you can change the local path where the repository will be saved by clicking the Choose... button, or you can just copy the path and paste it into the corresponding field.

- You can now proceed to click the Clone button and the repository will be cloned in the desired path/directory

The following video describes the step by step of everything that has been explained in this GitHub Clone Repository article:
