GIT Clone command with examples.
Learn how to create a copy of a git repository.
Cloning is the process of creating a duplicate of something. Git clone command creates a copy of the central repository in your workspace. This is the first step you should take prior to initiating any code changes. The original repository could be located on any of your LAN servers or via a hosted code management service such as BitBucket, Gitlab, or GitHub.
The origin is the URL that points to the central repository.
What do you need to clone a remote repository?
Typically, the origin is located on a server that is connected to the developer machine via an IP network. You must ensure that the local machine is connected to the server. For cloning, you must install the git software. The software client may include both a graphical user interface and a command-line interface. You can find installation instructions here.
In this tutorial, we’ll use Linux’s command-line interface. The same will be true for the Windows operating system.
How clone a repository with examples?
The clone is a very simple command to use. Most of the time only the origin URL is sufficient to pass as an argument. But it gives some options for additional arguments. Here we will explain each argument with an example.
Address of origin (repository URL path) –
This is the first argument to the command. It could be an HTTP, HTTPS, FTP, or SSH URL with a domain name or IP address along with the name of the repository, such as https://github.com/cspsprotocol/projectsource.git
git clone https://github.com/cspsprotocol/projectsource.git
Name of the folder (directory name) –
It is the name of the directory that the git clone command will use to copy all the source code. By default, the folder name will be the name of the repository without the .git suffix.
git clone https://github.com/cspsprotocol/projectsource.git folder-name
Clone all submodules (–recurse-submodules) –
A repository’s submodule is another repository. It could be a piece of third-party code or an entirely separate codebase. By default, the clone command does not include submodules while copying. This option copies and initializes all submodules.