GIT

Clone Git Remote Repository

In will help you to clone git remote repository on your local machine. After cloning the repository on local machine you will get the same file on your machine from where you can start working.

What is Git clone?

Git clone is a Git command line utility which is used to target an existing repository and create a clone, or copy of the target repository.

Cloning git is also known as a process of creating an identical copy of git remote repository to your local machine.

Follow these easy step to clone remote repository.

Create RSA SSH key pair

First of all you have to create a rsa ssh key pair to connect your remote server so that you no need to provide  password every time. This step also called key based login.

$ ssh-keygen

Generating public/private rsa key pair.
Enter file in which to save the key (/home/santosh/.ssh/id_rsa):
Created directory '/home/santosh/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/santosh/.ssh/id_rsa.
Your public key has been saved in /home/santosh/.ssh/id_rsa.pub.
The key fingerprint is:
99:e7:cd:fe:8e:c6:a0:eb:a0:c7:9f:5d:a3:91:b2:00 [email protected]
The key's randomart image is:
+--[ RSA 2048]----+
|                 |
|                 |
|                 |
|         o       |
|    E   S .      |
|     .   o.+     |
|     .o ..+o=    |
|     .oo.= =oo   |
|    .. o*.o.ooo  |
+-----------------+

Copy Public Key File on Remote server

Now you have to copy these rsa public key located at ~/.ssh/id_rsa.pub on you git server under git user account. To do this follow the below command:

$ ssh-copy-id -i ~/.ssh/id_rsa.pub [email protected]
 
 
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
[email protected]'s password:
 
Number of key(s) added: 1
 
Now try logging into the machine, with:   "ssh '[email protected]'"
and check to make sure that only the key(s) you wanted were added.

That’s all for setup key bases authentication. Now you can clone your git repository without providing password.

Clone Git Remote Repository

Let’s run the below command to copy your git remote repository on your local machine.

$ git clone [email protected]:projects/app1.git

Cloning into 'app1'...
warning: You appear to have cloned an empty repository.
Checking connectivity... done.

After running above command verify the URL of remote repository. You will get these below two URLs one for fetching and another for pushing permission.

$ git remote -v

origin	[email protected]:projects/app1.git (fetch)
origin	[email protected]:projects/app1.git (push)

Enjoy you have successfuly clone your remote git repository on your local machine.

If you want to learn more git related tutorial you can follow my Git Tutorials Page.

FAQs

Question 1 : How do I clone a remote git repository ?

Answer : If you want to clone git remote repository, first of all you have to copy the remote URL of repository for example GitHub url. Now you have to run the git clone command followed. Example : git clone {URL}.

Question 2 : How do I add a remote repository?

Answer : Run git remote add command to add remote repository in terminal.

Question 3 : What is a remote repository?

Answer : Remote repository is also called remote, it is repository that is hosted on remote location on the internet or another network.

Question 4 : What is git remote?

Answer : It’s a common repository that developer use to exchange their code changes.

Question 5 : How to I find my git remote origin?

Answer : If you want to view your git remote origin run git remote -v command. It will list the URLs of the remote repository.

Thank you! for visiting LookLinux.

If you find this tutorial helpful please share with your friends to keep it alive. For more helpful topic browse my website www.looklinux.com. To become an author at Look Linux Submit Article. Stay connected to Facebook.

About the author

mm

Santosh Prasad

Hi! I'm Santosh and I'm here to post some cool article for you. If you have any query and suggestion please comment in comment section.

Leave a Comment