Git - 克隆库

在这个Git教程中,您将学习如何在本地系统上远程仓库的克隆。这将复制所有远程到本地系统,你可以开始工作提供的应用程序文件。

1. 生成SSH密钥对

要连接服务器的Git,你可能需要配置基于密钥登录。因此,它不会提示每次您连接到服务器。
rahul@youcl:~$ ssh-keygen

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

2. 复制公钥到远程服务器

现在复制新generaed下Git帐户公共密钥(的~/.ssh/id_rsa.pub)git的服务器上。使用下面的命令来做到这一点。
rahul@youcl:~$ ssh-copy-id -i ~/.ssh/id_rsa.pub git@remote.example.com


/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
git@remote.example.com's password:

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh 'git@remote.example.com'"
and check to make sure that only the key(s) you wanted were added.

3. 克隆远程仓库

现在,使用下面的命令来使本地系统上远程Git仓库的克隆。
rahul@youcl:~$ git clone git@remote.example.com:project/app1.git

Cloning into 'app1'...
warning: You appear to have cloned an empty repository.
Checking connectivity... done.
在下面的命令代码中使用的本地副本验证远程URL。在结果你会看到两个网址,一个用于读取(fetch),一个用于推送(push)。
rahul@youcl:~/app1$ git remote -v 

origin	git@remote.example.com:project/app1.git (fetch)
origin	git@remote.example.com:project/app1.git (push)
赞(52) 打赏
未经允许不得转载:优客志 » 系统运维
分享到:

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏