Search
Close this search box.

Git Clone

Updated on: 6/15/2022

Git clone is used to copy an existing Git repository into a new local directory.

The Git clone command will create a new local directory for the repository, copy all the contents of the specified repository, create the remote tracked branches, and checkout an initial branch locally. By default, Git clone will create a reference to the remote repository called origin.

How to Git Clone a Repository

To Git clone a repository navigate to your preferred repository hosting service like GitHub, select the repository you want to clone, copy the repository URL via HTTPS or SSH, type git clone in the command line, paste the URL, and hit enter

Cloning a repo allows you to make local changes to the repository before committing and pushing them to the remote repository. 

This can be especially beneficial for beginner developers as cloning gives you a sandbox to experiment without affecting the original codebase (and angering your team members 😅). In this article, we’ll take an in-depth look at how to Git clone from the command line in GitKraken Desktop as well as from the GUI.

Git Clone Repository

Git Clone Topics Covered

Git Remote Repository URL Protocols

Git SSH Remote Protocol

Git Remote Protocol

HTTP(S) Remote Protocol

How to Git Clone over HTTPS using the Command Line

How to Git Clone over SSH using GitKraken Desktop

How to Git Clone over HTTPS using GitKraken Desktop

Git clone with GitKraken Desktop Integrations

Git Clone FAQs

GitKraken Desktop Makes it Easier to Git Clone 

Don’t risk compromising the security of your code. GitKraken Desktop allows secure connections to remote repositories – one less thing you have to worry about.

Git Remote Repository URL Protocols

The supported protocols for remote URLs in Git are SSH, Git, HTTP, and HTTPS.

Git SSH Remote Protocol

SSH stands for Secure Shell. Using Git SSH allows you to authenticate with a remote repository using a key.

Format of an SSH URL: ssh://{user}@{host}:{port}/path/to/repo.git or {user}@host:path/to/repo.git

To use Git SSH in the command line, you will need to generate a public and private SSH key, add the key to your SSH-agent, and add the public key to the remote hosting service.

Git Remote Protocol

The Git protocol is an unauthenticated method and should be used with caution.

Format of a Git URL: git://{host}:{port}/path/to/repo.git

HTTP(S) Remote Protocol

HTTP(S) stands for Hyper Text Transfer Protocol (Secure). Using HTTPS allows you to authenticate with the repository using username and password credentials.

Compared with HTTP, HTTPS is a more secure version.

Format of an HTTPS URL: https://{host}:{port}/path/to/repo.git

GitTip: Learn more about local Git repositories and remote repositories with our beginner Git tutorial video series.

Follow along with the upcoming examples of cloning in GitKraken Desktop and the command line using this GitHub practice repo.

Practice Cloning

How to Git Clone over HTTPS using the Command Line

In this example, we will go over the process of cloning a GitHub repository over HTTPS. To clone a Git repository, you will first copy the remote URL from your repository hosting service—in this case GitHub.

You will then use the Git clone command followed by the remote repo’s URL.

git clone <repository-url>

If you are working with a private repository, you will be prompted for your remote hosting service credentials.

After cloning, you can change directories (cd <path>) into the repository to begin working in it. There are many additional flags that can be used while cloning for things like naming the local directory, naming the remote, or checking out a branch.

How to Git clone over SSH using GitKraken Desktop

If you are using a URL to clone over SSH with GitKraken Desktop, you will first need to configure Git SSH in the Git client. GitKraken Desktop has a built-in SSH-agent that makes working with SSH keys, including GitHub SSH keys, very easy.

Your GitKraken Desktop SSH settings can be found under Preferences > SSH. Here, you can generate a new SSH key, point to an existing key, or use your local SSH-agent to manage SSH.

If this is your first time using SSH through GitKraken Desktop, you will need to add the SSH key to the remote hosting service—in this case, GitHub. You will simply copy the public key from GitKraken Desktop, and add it under the settings section of your hosting service.

After you have completed those steps, you will be able to simply provide the SSH URL to clone remote repositories with GitKraken Desktop.

For more information on working with SSH in GitKraken Desktop, see our Git SSH documentation. GitHub also has a great guide for how to work with SSH.

How to Git clone over HTTPS using GitKraken Desktop

If you’re using a URL to clone over HTTPS with GitKraken Desktop, you simply provide the remote URL when prompted to do so.

Here, you will also set the local path to clone and the local repository directory name.

Git Clone with GitKraken Desktop Integrations

GitKraken Desktop offers integrations for the following remote repository hosting services to make cloning, as well as many other actions, even easier:

As seen below, each hosting service integration you have connected to your GitKraken Desktop account will list all of the remote repositories available to clone.

HTTPS is the default remote protocol in GitKraken Desktop. After connecting to your remote repository hosting service, you will not be required to fill out your credentials while working over HTTPS as the integration uses OAuth or a PAT (Personal Access Token) to authenticate.

For each of these integrations, you can quickly create an SSH key or point to an existing one. Generating an SSH key will automatically add it to the hosting service, removing the need to manually copy it from one platform and add it to another.

You can manage your GitKraken Desktop integrations at any time by navigating to Preferences > Integrations. In this example, you can see GitKraken Desktop is creating a GitHub SSH key.

Alternatively, if you would like to point to an existing SSH key, you can add the public SSH key to the hosting service with a single click.

Put your new skills to the test and practice cloning a repository with GitKraken using this instructional GitHub repo.

Practice Cloning

Frequently Asked Questions

Q: How to Clone a Git Repository

A: If you want to clone an existing Git repository, navigate to the repo you want to clone on your preferred code hosting service like GitHub or GitLab and select clone with SSH or HTTPS.

Q: How to Clone Git 

A: Git is a distributed version control software that allows you to track projects. It is unlikely that you will run into a situation where you would want to clone Git itself. Instead, using Git, you can Git clone a repository from a hosting service like GitHub, GitLab, and others via SSH or HTTPS. For more advanced cloning options like using git clone –shared, git clone –no checkout, and more, visit Git SCM

GitKraken Desktop Makes it Easier to Git Clone

The more your Git portfolio grows, the harder it will be to manage your library of remote repos. The GitKraken Git client can help organize your remotes from multiple hosting services, giving you the ability to quickly find and clone the repo you need.

Additional Resources

Table of Contents

Visual Studio Code is required to install GitLens.

Don’t have Visual Studio Code? Get it now.

Team Collaboration Services

Secure cloud-backed services that span across all products in the DevEx platform to keep your workflows connected across projects, repos, and team members
Launchpad – All your PRs, issues, & tasks in one spot to kick off a focused, unblocked day. Code Suggest – Real code suggestions anywhere in your project, as simple as in Google Docs. Cloud Patches – Speed up PR reviews by enabling early collaboration on work-in-progress. Workspaces – Group & sync repos to simplify multi-repo actions, & get new devs coding faster. DORA Insights – Data-driven code insights to track & improve development velocity. Security & Admin – Easily set up SSO, manage access, & streamline IdP integrations.
winget install gitkraken.cli