git clone <repo_url>
This command is useful when you want to start working on an existing project by copying the entire Git repository history and files from a remote location to your local machine.
This command contacts the remote repository at <repo_url>, downloads all its commits, branches, and tags, and creates a new directory named after the project, setting up a local main or master branch that tracks the remote default branch; the <repo_url> can be an https URL, an ssh URL, or a local path, and the basic form is enough to get a complete working copy linked to the original remote as origin. You can control the target directory name by adding another argument like git clone <repo_url> <directory_name>, or use flags such as -b/--branch <branch_name> to clone and check out a specific branch, --depth <n> for a shallow clone with only the last n commits, and --single-branch to avoid downloading all remote branches when you only care about one. Flags like --recurse-submodules will also initialize and update submodules, while --origin <name> lets you rename the default remote from origin to something else.
Variants that are closely related include git clone --depth 1 <repo_url> for a minimal history copy, git clone -b <branch_name> --single-branch <repo_url> when you only need one branch, and git clone --recurse-submodules <repo_url> when the project depends on submodules; after cloning, commands like git fetch, git pull, and git remote -v complement this command by updating your local copy and inspecting configured remotes. You might also use git init in an empty directory instead of cloning when you are starting a brand-new repository rather than copying an existing one.
Examples:
git clone https://github.com/user/my-project.gitgit clone git@github.com:user/my-project.gitgit clone https://github.com/user/my-project.git my-local-folder