Skip to main content

Esta versão do GitHub Enterprise foi descontinuada em 2022-10-12. Nenhum lançamento de patch será feito, mesmo para questões críticas de segurança. Para obter melhor desempenho, segurança aprimorada e novos recursos, atualize para a última versão do GitHub Enterprise. Para obter ajuda com a atualização, entre em contato com o suporte do GitHub Enterprise.

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.

About cloning a repository

You can clone a repository from your GitHub Enterprise Server instance to your local computer to make it easier to fix merge conflicts, add or remove files, and push larger commits. When you clone a repository, you copy the repository from your GitHub Enterprise Server instance to your local machine.

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. 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 Git".

You can clone your existing repository or clone another person's existing repository to contribute to a project.

Cloning a repository

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

  2. Acima da lista de arquivos, clique em Código. Botão "Código"

  3. Copie a URL do repositório.

    • Para clonar o repositório usando HTTPS, em "HTTPS", clique em .
    • Para clonar o repositório usando uma chave SSH, incluindo um certificado emitido pela autoridade de certificação SSH da sua organização, clique em SSH e em .
    • Para clonar um repositório usando GitHub CLI, clique em GitHub CLI e selecione . O ícone da área de transferência para copiar a URL para clonar um repositório com o CLI do GitHub
  4. Abra TerminalTerminalGit Bash.

  5. Altere o diretório de trabalho atual para o local em que deseja ter o diretório clonado.

  6. Digite git clone e cole a URL já copiada.

    $ git clone https://hostname/YOUR-USERNAME/YOUR-REPOSITORY
  7. Pressione ENTER para criar seu clone local.

    $ 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.

Para saber mais sobre a GitHub CLI, confira "Sobre a GitHub CLI".

To clone a repository locally, use the repo clone subcommand. Replace the repository parameter with the repository name. For example, octo-org/octo-repo, monalisa/octo-repo, or octo-repo. If the OWNER/ portion of the OWNER/REPO repository argument is omitted, it defaults to the name of the authenticating user.

gh repo clone REPOSITORY

You can also use the GitHub URL to clone a repository.

gh repo clone https://github.com/PATH-TO/REPOSITORY
  1. On your GitHub Enterprise Server instance, navigate to the main page of the repository.
  2. Acima da lista de arquivos, clique em Código. Botão "Código"
  3. Clique em Abrir com o GitHub Desktop para clonar e abrir o repositório com o GitHub Desktop. Botão "Abrir com o GitHub 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 your GitHub Enterprise Server instance, 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, including a certificate issued by your organization's SSH certificate authority, 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. Abra TerminalTerminalGit Bash.

  4. Altere o diretório de trabalho atual para o local em que deseja ter o diretório clonado.

  5. Digite git clone e cole a URL já copiada.

    $ git clone https://hostname/YOUR-USERNAME/YOUR-REPOSITORY
  6. Pressione ENTER para criar seu clone local.

    $ 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: