What does the Git clone command do?

Experience Level: Junior
Tags: GitSource control

Answer

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

Comments

No Comments Yet.
Be the first to tell us what you think.
Git for beginners
Git for beginners

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

Test yourself
25 Git questions that will help you to nail your job interview
25 Git questions that will help you to nail your job interview

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

Test yourself