git clone <repo_url> <local_repo_name>
Creates a copy of a remote repository with a different name on your local machine
This command creates a copy of a remote repository on your local machine. The repo_url
parameter specifies the URL of the remote repository, while the local_repo_name
parameter specifies the name of the local repository directory to be created.
By default, the git clone
command creates a remote tracking branch named origin/master
, which is set to track the master
branch of the remote repository. However, you can specify a different branch to track using the --branch
or -b
flag followed by the branch name.
Other useful flags include:
--depth
to specify the depth of the clone, allowing you to fetch only a specific number of commits or a certain time period of the repository's history.--single-branch
to only clone a specific branch of the remote repository.--recurse-submodules
to automatically initialize and clone any submodules associated with the repository.
Examples:
git clone https://github.com/user/repo.git myrepo
creates a local copy of therepo
repository in a directory namedmyrepo
.git clone --branch develop https://github.com/user/repo.git
clones thedevelop
branch of the remote repository.
Related