Git Examples logoGit Examples
ListCheatsheetReviewQuizRecipesStatsSearch

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 the repo repository in a directory named myrepo.
  • git clone --branch develop https://github.com/user/repo.git clones the develop branch of the remote repository.
Related commands

    git clone <repo_url>

Follow me for updates: @carlesandres
ListReviewSearch

Welcome to GitExamples!

Sign in to enable bookmarking, reminders, progress-tracking and more...

Welcome to Git Examples

Git Examples is the quick way to get better at Git.

Git by Example

With more than 100 examples, you can always find a new Git secret.

Bookmark

Bookmark commands to create a personalized cheatsheet that you can print.

Deep Dive

Learn more about any Git command by clicking on the command name.

Mark for Review

Mark commands for review to revisit them later.

Take a quiz

Test your knowledge with a fun quiz.