Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Cloning a Remote Repository | Introduction to GitHub
GitHub Fundamentals

Cloning a Remote RepositoryCloning a Remote Repository

Cloning

Once a remote repository has been created, you can create a local copy by using the git clone command with the URL of the repository. However, before running any commands, let's first recap how to open the Terminal (Git Bash) on your operating system.

Windows Instructions

  1. Click on the Start menu or press the Windows key.
  2. Type Git Bash in the search bar.
  3. Click on the Git Bash application from the search results.
Finding Git Bash

macOS Instructions

  1. Press Command (⌘) + Space simultaneously. This will open Spotlight, a system-wide search feature.
  2. Type "Terminal" in the search bar, and you'll see "Terminal" or "Terminal.app" as one of the results.
  3. Click on "Terminal" in the search results. This will open the Terminal application.
Finding Terminal in Spotlight

Linux Instructions

  1. Press the Ctrl + Alt + T
In case you do not have Git installed, our article will provide you with a step-by-step installation guide.

Now, you will need the URL, so follow the instructions in the video below to learn how to copy the URL of your repository on GitHub.

With the URL copied, we are now ready to clone our remote repository via running the following command in the terminal and replacing <url> with the actual URL of your repo:

You can zoom in on every terminal screenshot in this course by clicking on it.

As you can see, we have successfully downloaded a copy of the remote repository from GitHub to our local machine. Additionally, a directory named github-playground was automatically created, containing the entire working tree.

Let's now switch to this directory and list all its non-hidden files and directories:

Essentially, our repo contains only a single README.md file, which was created automatically with the repository in the preivous chapter.

A README file is a document that usually provides essential information about a software project, such as setup instructions, features, and dependencies, usually written in markdown. Markdown is a lightweight markup language with plain text formatting syntax, designed to be converted to HTML and other formats while being easy to read and write.

Committing Changes Locally

Let's now modify this file by editing its contents. We will use the Vim editor for this. To open the README.md file in Vim, run the following command:

First, you have to enter insert (edit) mode in Vim by pressing i. This allows you to edit the text. Next, let's add the following line to our README file:

To exit insert mode, press the Escape key. Afterward, to save the changes and exit, type :wq and press the Enter key:

Let's now check the status of our working tree:

As you can see, it is stated that the README file is in the modified state, so we can now stage and commit this change in a single command:

To recap, the -a parameter in the git commit command automatically stages all the modified and deleted files, skipping the need for git add before committing. The -m parameter allows you to include a commit message directly in the command.

Which command is used to create a local copy of a remote repository?

Selecciona la respuesta correcta

¿Todo estuvo claro?

Sección 1. Capítulo 5
course content

Contenido del Curso

GitHub Fundamentals

Cloning a Remote RepositoryCloning a Remote Repository

Cloning

Once a remote repository has been created, you can create a local copy by using the git clone command with the URL of the repository. However, before running any commands, let's first recap how to open the Terminal (Git Bash) on your operating system.

Windows Instructions

  1. Click on the Start menu or press the Windows key.
  2. Type Git Bash in the search bar.
  3. Click on the Git Bash application from the search results.
Finding Git Bash

macOS Instructions

  1. Press Command (⌘) + Space simultaneously. This will open Spotlight, a system-wide search feature.
  2. Type "Terminal" in the search bar, and you'll see "Terminal" or "Terminal.app" as one of the results.
  3. Click on "Terminal" in the search results. This will open the Terminal application.
Finding Terminal in Spotlight

Linux Instructions

  1. Press the Ctrl + Alt + T
In case you do not have Git installed, our article will provide you with a step-by-step installation guide.

Now, you will need the URL, so follow the instructions in the video below to learn how to copy the URL of your repository on GitHub.

With the URL copied, we are now ready to clone our remote repository via running the following command in the terminal and replacing <url> with the actual URL of your repo:

You can zoom in on every terminal screenshot in this course by clicking on it.

As you can see, we have successfully downloaded a copy of the remote repository from GitHub to our local machine. Additionally, a directory named github-playground was automatically created, containing the entire working tree.

Let's now switch to this directory and list all its non-hidden files and directories:

Essentially, our repo contains only a single README.md file, which was created automatically with the repository in the preivous chapter.

A README file is a document that usually provides essential information about a software project, such as setup instructions, features, and dependencies, usually written in markdown. Markdown is a lightweight markup language with plain text formatting syntax, designed to be converted to HTML and other formats while being easy to read and write.

Committing Changes Locally

Let's now modify this file by editing its contents. We will use the Vim editor for this. To open the README.md file in Vim, run the following command:

First, you have to enter insert (edit) mode in Vim by pressing i. This allows you to edit the text. Next, let's add the following line to our README file:

To exit insert mode, press the Escape key. Afterward, to save the changes and exit, type :wq and press the Enter key:

Let's now check the status of our working tree:

As you can see, it is stated that the README file is in the modified state, so we can now stage and commit this change in a single command:

To recap, the -a parameter in the git commit command automatically stages all the modified and deleted files, skipping the need for git add before committing. The -m parameter allows you to include a commit message directly in the command.

Which command is used to create a local copy of a remote repository?

Selecciona la respuesta correcta

¿Todo estuvo claro?

Sección 1. Capítulo 5
some-alt