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

Course Content

GitHub Fundamentals

GitHub Fundamentals

1. Introduction to GitHub
2. Basic Interaction with Remotes
3. More Advanced Workflows

book
Cloning 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.

Note
Note

In case you do not have Git installed, our article will provide you with a step-by-step installation guide.

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:

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 previously.

Note
Study More

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

To make your first local commit, start by editing the README.md file. You can use any editor you preferβ€”like Notepad, Visual Studio Code, or Sublime Text. In this example, Vim editor will be used (here you can install Vim).

To open the README.md file in Vim, run:

Committing Changes Locally

Let's 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:

Note
Note

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.

question mark

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

Select the correct answer

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 1. ChapterΒ 5

Ask AI

expand
ChatGPT

Ask anything or try one of the suggested questions to begin our chat

course content

Course Content

GitHub Fundamentals

GitHub Fundamentals

1. Introduction to GitHub
2. Basic Interaction with Remotes
3. More Advanced Workflows

book
Cloning 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.

Note
Note

In case you do not have Git installed, our article will provide you with a step-by-step installation guide.

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:

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 previously.

Note
Study More

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

To make your first local commit, start by editing the README.md file. You can use any editor you preferβ€”like Notepad, Visual Studio Code, or Sublime Text. In this example, Vim editor will be used (here you can install Vim).

To open the README.md file in Vim, run:

Committing Changes Locally

Let's 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:

Note
Note

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.

question mark

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

Select the correct answer

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 1. ChapterΒ 5
We're sorry to hear that something went wrong. What happened?
some-alt