The Git command git clone is used to "clone" an existing remote repository on GitHub, for example, to your local machine. By executing the command, you create a local copy of a repository that already exists remotely on GitHub, GitLab, BitBucket, or a private server within your company.
Git Clone Command
Here's the command syntax for the git clone command:
$ git clone <URL>
You need to replace the <URL> part of this command with the URL of the remote repository you want to clone. A full working command could look, for example, like this:
$ git clone https://github.com/CodingNomads/testing_git.git
Info: No need to clone this repository right now; you will work with it in just a bit.
Git Clone vs Git Init
It isn't uncommon to mix up git init with git clone. However, they accomplish different things:
git initis used to initialize a new repositorygit clonecopies an existing repository using its URL
Info: You will learn more about git init in an upcoming lesson.
Cloning in Git
There are different ways of cloning a remote repository from GitHub:
- Using the
httpsURL in our terminal - Using an
sshkey - Downloading a
zipfile - Clone with the GitHub CLI
In the next lesson, you will learn to use these different methods for getting a local copy of a remote repository.