Git

What is Git Clone? | Beginner Git Tutorial

Git cloning is the process of duplicating any targeted repository, which can be a local repository or a remote repository. Developers can clone the remote repository to make a duplicate copy on their system. As a result, they get a copy of the history, and it is a functional Git repo. Moreover, the users can also sync between the two locations.

In this blog, you will learn:

So, let’s start!

How to Clone Remote Repository With HTTPS?

The Hyper Transfer Protocol Secure (HTTPS) is a secure version of the HTTP which encrypts data transmitted between the server and the user. It is pretty straightforward to access and write on repositories from all over the globe whenever the user needs it.

To clone the remote repository with HTTPS, first, we will navigate to the local directory. Then, move to the remote hosting service, select the repository, and copy the repository HTTPS URL. Lastly, execute the “$ git clone <https-url>” command to clone the repository.

Now, let’s move toward the repository cloning procedure using the HTTPS URL!

Step 1: Navigate to Repository

Move to the Git local directory by using provided command:

$ cd "C:\Users\nazma\Git\remote-repo"

Step 2: Copy HTTPS URL

Next, open up the remote repository and copy the HTTPS URL to the clipboard:

Step 3: Clone Repository

Finally, run the below-given command with copied URL and clone it to the local repository:

$ git clone https://github.com/GitUser0422/demo3.git

Now, move toward the next section to clone the remote repository to the local repository using the SSH URL.

How to Clone Remote Repository With SSH URL?

The SSH means “Secure Shell” protocol which is also a secured version, where data sent between the client and server is encrypted. SSH is configured with a pair of public and private keys.

To clone Git remote repository using the SSH URL, open up the remote repository and click on the “Code” button and copy the SSH URL. Then, execute the “$ git clone <ssh-url>” command to clone a remote repository using SSH copied URL.

Let’s try out the steps below to clone the remote repository using the SSH URL!

Step 1: Copy SSH URL

First, go to the remote repository and copy the SSH URL:

Step 2: Clone Repository

Then, execute the “git clone” command to clone the remote repository by utilizing the SSH URL:

That’s all! We have explained the procedure of remote repository cloning through the HTTPS and SSH URLs.

Conclusion

Git cloning is the procedure of creating a copy of the target repository, which can be a Git local repository or a remote repository. To clone a remote repository to a local repository, you can specify either the HTTPS or SSH URL in the “$ git clone <ssh or https-url>” command. In this blog, we have demonstrated how to clone the repository with HTTPS and SSH URLs.

About the author

Maria Naz

I hold a master's degree in computer science. I am passionate about my work, exploring new technologies, learning programming languages, and I love to share my knowledge with the world.