This version of GitHub Enterprise will be discontinued on This version of GitHub Enterprise was discontinued on 2020-05-23. No patch releases will be made, even for critical security issues. For better performance, improved security, and new features, upgrade to the latest version of GitHub Enterprise. For help with the upgrade, contact GitHub Enterprise support.

Article version: Enterprise Server 2.17

Cloning a repository

When you create a repository on your GitHub Enterprise Server instance, it exists as a remote repository. You can clone your repository to create a local copy on your computer and sync between the two locations.

In this article

About cloning a repository

When you're working with a repository on your GitHub Enterprise Server instance, you might want to have it on your local machine to make it easier to work with. For example, to allow you to use your favorite editor, to add and remove files, or to fix conflicts. The process of copying the repository from your GitHub Enterprise Server instance to your local machine is called cloning (sometimes referred to on other version control systems as "checking out").

Cloning a repository pulls down a full copy of all the repository data that your GitHub Enterprise Server instance has at that point in time, including all versions of every file and folder for the project. At any point, you can push your changes to the remote repository on your GitHub Enterprise Server instance, or pull other people's changes from your GitHub Enterprise Server instance. For more information, see "Using common Git commands".

You can either clone your existing repository or, to contribute to a project, clone another person's existing repository. For more information, see "Creating a new repository".

Cloning a repository using the command line

  1. On GitHub Enterprise, navigate to the main page of the repository.
  2. Under the repository name, click Clone or download.
    Clone or download button
  3. To clone the repository using HTTPS, under "Clone with HTTPS", click . To clone the repository using an SSH key click Use SSH, then click .
    Clone URL button
  4. Open TerminalTerminalGit Bash.
  5. Change the current working directory to the location where you want the cloned directory.
  6. Type git clone, and then paste the URL you copied earlier.
    $ git clone https://hostname/YOUR-USERNAME/YOUR-REPOSITORY
  7. Press Enter to create your local clone.
    $ git clone https://hostname/YOUR-USERNAME/YOUR-REPOSITORY
    > Cloning into `Spoon-Knife`...
    > remote: Counting objects: 10, done.
    > remote: Compressing objects: 100% (8/8), done.
    > remove: Total 10 (delta 1), reused 10 (delta 1)
    > Unpacking objects: 100% (10/10), done.

Cloning a repository to GitHub Desktop

  1. On GitHub Enterprise, navigate to the main page of the repository.
  2. Under the repository name, click Clone or download.
    Clone or download button
  3. To clone your repository in GitHub Desktop, under "Clone with HTTPS", click Open in Desktop
  4. Follow the prompts in GitHub Desktop to complete the clone.

For more information, see "Cloning a repository from GitHub to GitHub Desktop."

Cloning an empty repository

An empty repository contains no files. It's often made if you don't initialize the repository with a README when creating it.

  1. On GitHub Enterprise, navigate to the main page of the repository.

  2. To clone your repository using the command line using HTTPS, under "Quick setup", click . To clone the repository using an SSH key click SSH, then click .

    Empty repository clone URL button

    Alternatively, to clone your repository in Desktop, click Set up in Desktop and follow the prompts to complete the clone.

    Empty repository clone desktop button

  3. Open TerminalTerminalGit Bash.

  4. Change the current working directory to the location where you want the cloned directory.

  5. Type git clone, and then paste the URL you copied earlier.

    $ git clone https://hostname/YOUR-USERNAME/YOUR-REPOSITORY
  6. Press Enter to create your local clone.

    $ git clone https://hostname/YOUR-USERNAME/YOUR-REPOSITORY
    > Cloning into `Spoon-Knife`...
    > remote: Counting objects: 10, done.
    > remote: Compressing objects: 100% (8/8), done.
    > remove: Total 10 (delta 1), reused 10 (delta 1)
    > Unpacking objects: 100% (10/10), done.

Troubleshooting cloning errors

When cloning a repository it's possible that you might encounter some errors.

If you're unable to clone a repository, check that:

Ask a human

Can't find what you're looking for?

Contact us