What is Git Clone and How to Clone a Git repository?

git clone copies an existing Git repository to your local computer. You get all the files, all branches and the full history, and Git also sets a remote named origin which points to the original place.

Syntax:

git clone <repository-url>
git clone <repository-url> <folder-name>

Example:

git clone https://github.com/username/project.git

Git creates a folder with the name of the repository (project) and downloads everything in it. To use a different folder name, write it after the URL. The URL can be HTTPS, SSH or a local path.

See the chapter Git Clone for more options like --branch and --depth 1.


Learn more about the similar topics:
Tutorials
Git Clone
Git Remote
Git Push
Git Fetch and Pull
Exercises & Assignments
Clone a repository, make a change and push it
Get new changes from the remote with fetch and pull
Interview Questions & Answers
What is Git Clone and How to Clone a Git repository?
How can you push changes to a remote branch in Git?
What is the difference between git fetch and git pull?
What is the difference between git clone and fork?
What is origin in Git?
What is a pull request?
What is the difference between force push and force with lease in Git?