"Cloning" in simple English ways producing identical individuals either naturally or artificially. If you are familiar with the term, there is no surprise what is going to exist in this tutorial. Before coming on to What is Cloning in Git or Git Clone , I promise the reader is well-versed with the process of Forking in GitHub .

Sometimes, non-technical people or the people who have not all the same worked on Git consider these two terms (Git Clone & Git Fork) as similar. Actually, they are, simply with some differences. It is ameliorate to rinse your brain with forking before learning the concept of cloning in Git.

As well, since the nuts of Git and GitHub have already been covered in this course, from at present on nosotros will utilise both of them to perform the operations and procedures on our code/files. On the greater circle, this tutorial volition brand you familiar with:

  • What is Cloning?
  • Purpose of Cloning
  • Importance of Cloning in Git
  • Cloning a repository and Git Clone command

What is Git Clone or Cloning in Git?

Cloning is a process of creating an identical copy of a Git Remote Repository to the local machine.

Now, y'all might wonder, that is what we did while forking the repository!!

Git Clone

When we clone a repository, all the files are downloaded to the local machine but the remote git repository remains unchanged. Making changes and committing them to your local repository (cloned repository) will not affect the remote repository that you cloned in any manner. These changes made on the local motorcar tin can be synced with the remote repository anytime the user wants.

Why Clone a Repository?

Equally mentioned in the previous sections, cloning downloads the complete source code to the local organization, let's go through the real reasons why cloning is required ar the first identify:

  • Contribute to Organizational Projects : A centralized system is required for organizations where multiple people work on the same code base. Cloning helps us accomplish this motive. Past cloning, people can edit the project lawmaking to either gear up some issue or provide some modifications i.east. an extra or extended feature. This definitely helps in producing better software in less time with greater collaboration.
  • Brand utilise of Open Source Repositories : A famous idiom in English, "Do not reinvent the bike" is suitable for this point to sympathize. Similarly, if someone wants to utilise some functionality that has already been developed by someone else, then why to code information technology from scratch and waste fourth dimension & resources? For e.1000. in that location are unlimited opensource repositories are available, which can directly fit into the projects.

Since cloning is so of import office of the Git and GitHub journeying, it is meliorate to run across in detail how cloning works. It is a very uncomplicated and straightforward process to which the adjacent section is defended.

How does Cloning in Git works?

A lot of people desire to fix up a shared repository to allow a team of developers to publish their lawmaking on GitHub / GitLab / BitBucket etc. A repository that is uploaded online for collaboration is called an Upstream Repository or a Fundamental Repository .

A central repository indicates that all the changes from all the contributors pushed into this repository just. So, this is the virtually updated repository instance of itself. Sometimes this is often chosen the original repository . Now, the prototype given beneath is pretty articulate nearly the concept of cloning.

Git Clone - Cloning a Repo

With respect to the above paradigm, the cloning process works in these steps:

  • Clone a Repository : The user starts from the upstream repository on GitHub. Since the user navigated to the repository because he/she is interested in the concept and they like to contribute. The process starts from cloning when they clone the repository it into their local automobile. Now they have the exact re-create of the project files on their organisation to brand the changes.
  • Make the desired changes : Afterwards cloning, contributors provide their contribution to the repository. Contribution in the class of editing the source files resulting in either a bug set or adding functionality or perhaps optimizing the lawmaking. But the bottom line is, everything happens on their local organization.
  • Pushing the Changes : In one case the changes are washed and now the modifications can be pushed to the upstream repository.

Notation : Owner of the repository tin can allow/disallow straight changes to Central Repository, set various notifications(notification for any modify pushed to central Repo) and many more, but all these settings volition exist covered later in this serial of Git Tutorial.

Git Clone

Cloning in Git tin be done on the self-owned repository or anyone else'south repository. In the following section, we will clone the ToolsQA repository bachelor on my GitHub business relationship. You can create a new GitHub repository and try to clone the same.

How to Clone a Repository or utilise Git Clone Control?

Cloning a repository from GitHub is a elementary procedure. Simply, before cloning, please ensure you have a repository on your GitHub business relationship. In this section, I volition brand utilize of the ToolsQA repository ( reference ).

  1. To clone a repository, get to the repository page which you want to clone. This can be washed through the side column on your dashboard.

repository_Section

  1. Press Clone or download push.

clone_or_download_button

  1. Re-create the code that appears after pressing the button.

copy_clone_code

Annotation : The Apply SSH function located beside Clone with HTTPS volition be explained in detail in the SSH tutorial simply as of now we are cloning the repository with https ("Clone with HTTPS") non ssh .

  1. Once done, open Git bash on your system.

navigate_to_repo

Note : Remember to change the directory to which y'all want to clone the repository. I have marked my directory Git Repo ToolsQA in the above image in which I will be cloning the repository from GitHub.

  1. Check the directories (or repositories) already created under this directory. (using ls command)

list_all_the_directories

As seen in the image, I have just i repository under the directory Git Repo ToolsQA.

  1. Press the following command to clone the repository:

git clone <URL>

URL here represents the aforementioned URL that we copied in the third footstep.

Git Clone Command

Note : URL is the link of the repository over GitHub Cloud. Y'all tin type this into the accost bar in your browser and check if the repository page opens or not.

  1. The post-obit message will announced equally you lot printing enter.

git_clone_successful

It would take a few seconds to clone the repository onto your system.

Note : Please annotation that cloning depends on the internet connection and the fourth dimension would depend on your connexion bandwidth. If Git is not able to clone due to a weak connection, information technology would display a fatal error and the user is requested to try over again until the to a higher place message does not appear.

  1. Ostend the cloning by listing the directories once over again using the ls command which lists all the files and binder.

list_all_the_directories_after_clone

Since the Centralised Repository in our instance called ToolsQA, the aforementioned has been copied to my local motorcar.

Check in the local drive by navigating to it manually.

Cloned_Repo_In_Local_Machine

As conspicuously seen, we have successfully cloned the repository from GitHub. Now nosotros tin can work on the files on our local organization similar normal code files. Cloning is very helpful as you might accept guessed and used very frequently by the people using Git or GitHub for their software evolution. Once the changes are made, the user pushes the changes to the original repository on the deject (GitHub) and makes it available to everyone who is watching it or contributing to it. Now it's the time to clear the fuzz betwixt Git Clone and Git Fork.