What does the Git clone command do?

Experience Level: Junior
Tags: Git Source control


The git clone command is used for creating a local repository from another repository.

It can be executed like this:

git clone <URL> <Folder>

  • The URL can be either physical path to anoher local repository (folder), or HTTP, HTTPS or SSH URL to the remote reposiory.
  • If you don't provide the <Folder> parameter, the repository will be created in a newly created folder that will be automatically derived from the <URL>
  • If you want to clone the repository directly to the current folder (use git clone <URL> .), the current folder must be empty

When the git clone is executed, it does the following steps for you:

  • New empty folder is created in your current folder
  • New empty .git folder is created in a newly created folder (this .git folder will contain all data of the target repository after the next step is completed)
  • Data from the target repository .git folder is copied to your newly created .git folder
Related Git job interview questions
Git for beginners
Git for beginners

Are you learning Git? Try our test we designed to help you progress faster.

Test yourself