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 |