如何克隆GitHub存储库

如何克隆GitHub存储库

Cloning a GitHub repository creates a local copy of the remote repo. This allows you to make all of your edits locally rather than directly in the source files of the origin repo. Here’s how to clone a GitHub repository.

克隆GitHub存储库将创建远程存储库的本地副本。 这使您可以在本地进行所有编辑,而不是直接在原始仓库的源文件中进行。 这是克隆GitHub存储库的方法。

The first thing you’ll need to do is download and install Git on your computer. The installation process is straightforward and brings you through a lot of boilerplate information. The one thing you want to be careful with is that you allow Git to be used from the command line.

您需要做的第一件事是在计算机上下载并安装Git 。 安装过程非常简单,并为您提供了大量样板信息。 您要小心的一件事是您允许从命令行使用Git。

如何克隆GitHub存储库

Let the wizard guide you through the rest. Once the installation is complete, you’ll be ready to clone the GitHub repository.

让向导指导您完成其余的工作。 安装完成后,就可以克隆GitHub存储库了。

The next thing you’ll want to do is decide where to store the repo on your local machine. We recommend making a memorable folder so that you can easily navigate to it using the Command Prompt later.

接下来要做的就是确定将回购存储在本地计算机上的位置。 我们建议您制作一个令人难忘的文件夹,以便以后可以使用命令提示符轻松导航到该文件夹​​。

Once you’ve decided where you’d like to store the repo, open your web browser and enter the GitHub repository’s URL. In this example, we’ll use a popular repository that contains JavaScript based examples meant for research and learning.

一旦确定了要存储此仓库的位置,请打开Web浏览器并输入GitHub存储库的URL。 在此示例中,我们将使用一个流行的存储库,该存储库包含用于研究和学习的基于JavaScript的示例

On the right side of the screen, below the “Contributors” tab, you’ll see a green button that says “Clone or Download.” Go ahead and click that. In the window that appears, select the “Clipboard” icon to copy the repo URL to your clipboard.

在屏幕右侧的“参与者”标签下,您会看到一个绿色按钮,上面显示“克隆或下载”。 继续并单击。 在出现的窗口中,选择“剪贴板”图标以将回购URL复制到剪贴板。

如何克隆GitHub存储库

Next, open the Command Prompt (on Windows) or whichever terminal you happen to be using on your computer.

接下来,打开命令提示符 (在Windows上)或您在计算机上碰巧使用的任何终端。

In the terminal, navigate to the location in which you would like to store the repo. You can do so by typing the following command:

在终端中,导航到您要存储回购的位置。 您可以通过键入以下命令来这样做:

$ cd <directory>

$ cd <directory>

In our example, we would enter $ cd Documents\GIT local .

在我们的示例中,我们将输入$ cd Documents\GIT local

如何克隆GitHub存储库

Note: You can skip this step by using git <repo-url> <directory> to clone the repo directly to the specified directory instead.

注意:您可以通过使用git <repo-url> <directory>将存储库直接克隆到指定目录来跳过此步骤。

Now, with the repo URL still copied to your clipboard, it’s time to clone the repo. Enter the following command:

现在,将回购URL仍复制到剪贴板,是时候克​​隆回购了。 输入以下命令:

$ git clone <repo-url>

$ git clone <repo-url>

In this case, we’d use $ git clone https://github.com/trekhleb/javascript-algorithms.git.

在这种情况下,我们将使用$ git clone https://github.com/trekhleb/javascript-algorithms.git

如何克隆GitHub存储库

Give the process a few moments to complete. Here’s what it looks like if everything went smoothly.

请花一点时间完成该过程。 如果一切顺利,这就是它的样子。

如何克隆GitHub存储库

As a matter of good practice, check to make sure that the repository is on your machine. To do so, navigate to the directory in which it was stored.

作为一种好的做法,请检查并确保存储库在您的计算机上。 为此,请导航到存储该目录的目录。

如何克隆GitHub存储库

You can see here that the “javascript-algorithms” repo was successfully cloned to our “Git local” folder.

您可以在此处看到“ javascript-algorithms”存储库已成功克隆到我们的“ Git local”文件夹中。

Now you can start making edits to the directory using your favorite text editor!

现在,您可以使用自己喜欢的文本编辑器开始对目录进行编辑!

翻译自: https://www.howtogeek.com/451360/how-to-clone-a-github-repository/