How to Clone a Repository
It is very important for developers to have a development copy of an existing git repository. When the user gets a working copy, all version control operations are managed through his local repository. To get a copy of the remote repository the git clone command comes to the rescue. It creates a clone/copy of an existing repository into a new directory.
Cloning a remote repository
In order to clone a remote repository git clone should be run:
git clone <repository-url>
Running this will clone the repository into the current directory using the name of it as the target directory.
So as to clone the repository into a different directory, you should run the following:
git clone <repository-url> <directory>
What is Cloning
The git clone command operates to fetch code from a remote repository. This command can be associated with git checkout which switches code versions on the local system. You should use git clone instead of checkout because when cloning a repository, a full copy of all data of the server will be received. It will pull down all the versions of the files for the project’s history, by default. Cloning is very important in case of server disk gets corrupted. You can set the server back to the state when it was cloned using any of the clones on any client.
What is the Difference Between git init and git clone
The git init and git clone are confused with each other. The git clone creates a copy of a repository that already exists. The git init command is used to generate a new, empty git repository or to reinitialize an existing one. Thus, for generating a git clone, you need a repository created with git init. Then, invoke git clone to copy the data that is included.