Are you looking for something? Here is all of the GitHub Docs history in one single commit. Enjoy! 🎉
2.4 KiB
2.4 KiB
title, intro, redirect_from, versions
| title | intro | redirect_from | versions | |||||
|---|---|---|---|---|---|---|---|---|
| Importing a Git repository using the command line | {% if currentVersion == "free-pro-team@latest" %}If [GitHub Importer](/articles/importing-a-repository-with-github-importer) is not suitable for your purposes, such as if your existing code is hosted on a private network, then we recommend importing using the command line.{% else %}Importing Git projects using the command line is suitable when your existing code is hosted on a private network.{% endif %} |
|
|
Before you start, make sure you know:
- Your {{ site.data.variables.product.product_name }} username
- The clone URL for the external repository, such as
https://external-host.com/user/repo.gitorgit://external-host.com/user/repo.git(perhaps with auser@in front of theexternal-host.comdomain name)
{% tip %}
For purposes of demonstration, we'll use:
- An external account named extuser
- An external Git host named
https://external-host.com - A {{ site.data.variables.product.product_name }} personal user account named ghuser
- A {{ site.data.variables.product.product_name }} repository named repo.git
{% endtip %}
- Create a new repository on {{ site.data.variables.product.product_name }}. 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/<em>extuser</em>/<em>repo.git</em>
# Makes a bare clone of the external repository in a local directory
- Push the locally cloned repository to {{ site.data.variables.product.product_name }} using the "mirror" option, which ensures that all references, such as branches and tags, are copied to the imported repository.
$ cd <em>repo.git</em>
$ git push --mirror https://{{ site.data.variables.command_line.codeblock }}/<em>ghuser</em>/<em>repo.git</em>
# Pushes the mirror to the new {{ site.data.variables.product.product_name }} repository
- Remove the temporary local repository.
$ cd ..
$ rm -rf <em>repo.git</em>