Before you start, make sure you know:
- Your GitHub Enterprise Server username
- The clone URL for the external repository, such as
git://external-host.com/user/repo.git(perhaps with a
user@in front of the
For purposes of demonstration, we'll use:
- An external account named extuser
- An external Git host named
- A GitHub Enterprise Server personal user account named ghuser
- A GitHub Enterprise Server repository named repo.git
- Create a new repository on GitHub Enterprise Server. You'll import your external Git repository to this new repository.
- On the command line, make a "bare" clone of the 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 https://external-host.com/extuser/repo.git # Makes a bare clone of the external repository in a local directory
- Push the locally cloned repository to GitHub Enterprise Server 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 https://hostname/ghuser/repo.git # Pushes the mirror to the new GitHub Enterprise Server repository
- Remove the temporary local repository.
$ cd .. $ rm -rf repo.git