git

«< Previous Next »>

Cloning

Cloning a repository means making a copy to work on locally. When you clone a repository from GitHub, information about where it was cloned from will automatically be added to your local version. This means that commands like git push will work without adding additional information.

git clone <repository-url>

For practice, let’s clone the repository for this session about Git and GitHub.

First, let’s navigate back to your Desktop folder.

cd ~/Desktop

Remember that the ~ refers to your home directory. Now let’s find the URL we need to clone the lesson.

First, follow this link to the main page of this lesson on Git and GitHub.

On the main page, there should be a green Code button on the right side:

Image pointing out where the Code button is on GitHub

Click the green button and you will see a popdown “Clone” box with a URL under a heading that says HTTPS. Copy out the text in the box:

Image showing where the text you need to copy is located

Now that you have the text copied, go back to your terminal. Remember, you should be on the desktop.

Type

git clone <copied-url>

If the command is successful, the full Git lesson will be replicated on your local machine. You can type

cd git

to enter the lesson folder, since the lesson repository is simply called git. Use the ls command to take a look at the various files in the lesson folder.

«< Previous Next »>