Git Clone Repository

In this blog post, we are going to discuss What is Cloning in Git or Git Clone, but before learning, if you have referred to the previous tutorials where we have discussed Git Fork or Forking in GitHub, then those will make you comfortable in understanding the git Clone concept easily.

If you have no prior working experience with Git, then such people think Git Fork and Git Clone both are similar. Actually, there are a few similarities between these two, but also some differences are also there. So it’s suggested that first, you learn about Git Fork, and then you try to learn Git Clone so that you can easily understand the differences and similarities.

Since the basics of Git and GitHub have already been covered in our previous blog posts, now, in this blog post, we are going to understand the following:

  • What is Git Clone or Cloning in Git?
  • Why Clone a Repository?
  • How does Cloning in Git work?

What is Git Clone or Cloning in Git?

If you want to create a copy of a remote repository on your local machine, you can use the git clone command. By default, this command will save your code in a local machine folder with the same name as your repository, but the remote git repository remains unchanged.

If you have made some changes and committed to your local repository (cloned repository), then those changes will not reflect on your remote repository. But you can synch your changes with a remote repository anytime.

Git Clone

However, if you want to choose a different name for the folder that holds your cloned code, you can specify it after the URL of the repository.

Why Clone a Repository?

As we mentioned, whenever we clone a repository, it will download all the complete source code into your local system, but let us try to understand by taking some real-time examples for a better understanding of why Git Clone is required.

Contribute to Organizational Projects: You’ll need a centralized system if you work on a code base with multiple people. Cloning can help with this by allowing people to edit the project code to fix issues or add features. This results in better software being produced in less time with greater collaboration.

Make use of Open Source Repositories: If someone wants to use functionality that has already been developed, they should look into open source repositories as these often have what people are looking for. This way, people can save time and resources.

Cloning is a vital part of the Git and GitHub experience, so let’s take a closer look at how it works. It’s actually quite simple and straightforward, as we’ll see now.

How does Cloning in Git work?

If you’re looking to set up a shared repository for your development team, GitHub/ GitLab/ BitBucket are all great platforms offering online collaboration repositories. These types of repositories are called Upstream Repositories or Central Repositories.

The central repository is the most up-to-date version of itself, containing all changes from all contributors. Sometimes, it’s referred to as the original repository.

Git Clone

As you see, the Git Clone process has gone through the below phases:

Clone a Repository: If you’re interested in contributing to a project, you can start by cloning the upstream repository onto your local machine. Cloning creates an exact copy of all the project files on your system so that you can make changes without affecting the original codebase.

Make the desired changes: After cloning, you can provide your contribution to the repository. Your contribution can be in the form of editing the source files, resulting in either a bug fix, adding functionality, or maybe optimizing the code. But remember, everything happens on your local system first.

Pushing the Changes: By making changes and then pushing them to the upstream repository or central repository, you can keep everyone up-to-date with the latest modifications.

Git Clone

You can clone a Git repository either from your own account or someone else’s. In the following section, we will clone the demo repository that is available on my GitHub account. You can create a new GitHub repository and try cloning it yourself to get some practice.

How to Clone a Repository or use Git Clone Command?

Before cloning a repository from GitHub, please ensure you have a repository on your GitHub account. To clone a repository, follow the steps below:

If you want to clone a repository, go to the page for that repository. You can find repositories on your dashboard in the sidebar.

Click on the demo repository link, and It will redirect you to the repository page.

GitHub Repository

Press the code button. After pressing the code button, it will open a popup.

Repository Page Code Button

From that popup, we need to copy the URL; you can do this by clicking the icon that is present beside the URL.

Copy the Repositoey URL

After copying, the URL opens your Git Bash on your system.

Git Clone Repository 1

Note: Be sure to change the directory to where you want the repository cloned. I have my directory, Git Repo democlone, marked in the image. That is where I will be cloning the repository from GitHub.

Go to the directory where you want to clone the repository, but before that, you can check if any files or directories are already present. You can do that by running the ls command like below.

Git Clone Repository 2

If there are any repositories or files, then those will be listed when you execute the ls command. Enter the following git clone command to clone the repository.

git clone

Example: git clone

Here, the URL is the same URL that we copied in our above steps (from the GitHub URL).

Git Clone Repository 3

Note: If you’re having trouble accessing your repository on GitHub Cloud, try typing ‘Git URL’ into the address bar in your browser. This should take you to the repository page.

The following message will appear when you press the enter key. Cloning the repository into your system will take a few seconds or minutes based on the file size.

Git Clone Repository 4

Note: If you’re having trouble accessing a GitHub repository, try checking the repository’s RL. You can do this by typing the RL into your browser’s address bar. If the repository page opens, then you should be able to access it.

After the completion of the Cloning process, the user can validate or confirm by executing the ls command.

Git Clone Repository 5

For our example, we have taken the central repository as a demo. So the same is downloaded to our local system.

We can also confirm this by manually navigating our local system.

Git Clone Repository 6

As you can see, we were able to clone the repository from GitHub. This is helpful because now we can work on the files locally, like with any other code file. Cloning is a very useful tool that is used frequently by those who develop software using Git or GitHub.

Once changes are made, the user pushes them back up to the original repository on GitHub, making it available to everyone else watching or contributing to it.

Categories GIT

I love open-source technologies and am very passionate about software development. I like to share my knowledge with others, especially on technology that's why I have given all the examples as simple as possible to understand for beginners. All the code posted on my blog is developed, compiled, and tested in my development environment. If you find any mistakes or bugs, Please drop an email to, or You can join me on Linkedin.

Leave a Comment