Skip to main content

Импорт внешнего репозитория Git с помощью командной строки

Если исходный код отслеживается в репозитории Git, вы можете импортировать репозиторий с помощью Git в командной строке.

Before you start, make sure you know:

  • Your GitHub Enterprise Cloud username
  • The clone URL for the external repository, such as or git:// (perhaps with a user@ in front of the domain name)

For purposes of demonstration, we'll use:

  • An external account named extuser
  • An external Git host named
  • A GitHub Enterprise Cloud personal account named ghuser
  • A repository on named repo.git
  1. Create a new repository on GitHub Enterprise Cloud. You'll import your external Git repository to this new repository.

  2. On the command line, make a "bare" clone of the external repository using the external clone URL. This creates a full copy of the data, but without a working directory for editing files, and ensures a clean, fresh export of all the old data.

    $ git clone --bare
    # Makes a bare clone of the external repository in a local directory
  3. Push the locally cloned repository to GitHub Enterprise Cloud using the "mirror" option, which ensures that all references, such as branches and tags, are copied to the imported repository.

    $ cd REPO.git
    $ git push --mirror
    # Pushes the mirror to the new repository on
  4. Remove the temporary local repository.

    cd ..
    rm -rf REPO.git

If the repository you are importing contains large files, you may run into a warning or error. For more information on large files and how to manage them, see "About large files on GitHub."

Further reading