[[code-repo-management]]
== Repo management

Code starts with an overview of your repositories.  You can then use the UI to add, delete, and reindex a repo.
[role="screenshot"]
image::images/code-repo-management.png[]

[float]
[[add-delete-a-repo]]
==== Add and delete a repo
The <<code-import-first-repo, Import your first repository>> page provides step-by-step instructions for adding a GitHub repo to *Code*.  You can fine-tune the hostname of the git clone URL in your `kibana.yml` file.

For security reasons, Code allows only a few <<clone-url-management,trusted hostnames>>, such as github.com. To clone private repositories see <<clone-private-repo,add an SSH key>>.

To delete a repository, go to the **Repositories** tab, find the name of the repo, and click *Delete*.

[float]
[[clone-private-repo]]
==== Clone private repo with an SSH key
Clones of private repos require an SSH key for authentication. The username associated with your host must have write access to the repository you want to clone.

The following section provides links for generating your ssh key through GitHub. If you already have an SSH key added through your host, skip to step 4.

1. https://help.github.com/en/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent#generating-a-new-ssh-key[Generate an ssh key].

2. https://help.github.com/en/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent#adding-your-ssh-key-to-the-ssh-agent[Add the ssh key to your ssh-agent.]

3. https://help.github.com/en/articles/adding-a-new-ssh-key-to-your-github-account[Add the ssh key to your host].

4. Copy the ssh key into `data/code/credentials/` under the {kib} folder.

You can now copy private Git repositories into Code.

To delete a repository, find the go to the **Repositories** tab, find the name of the repo and click *Delete*.

[float]
[[reindex-a-repo]]
==== Reindex a repo
*Code* automatically reindexes an imported repo at set intervals, but in some cases, you might need to refresh the index manually. For example, you might refresh an index after a new language server installs. Or, you might want to update the index to the HEAD revision immediately. Click *Reindex* to initiate a reindex.

[float]
[[clone-url-management]]
==== Clone URL management
For security reasons, *Code* only allows the following hostnames in the git clone URL by default:

- `github.com`
- `gitlab.com`
- `bitbucket.org`
- `gitbox.apache.org`
- `eclipse.org`

You can add your own hostname (for example, acme.com) to the whitelist by adding the following line to your `config/kibana.yaml` file:

[source,yaml]
----
xpack.code.security.gitHostWhitelist: [ "github.com", "gitlab.com", "bitbucket.org", "gitbox.apache.org", "eclipse.org", "acme.com" ]
----

Set `xpack.code.security.gitHostWhitelist` to [] (empty list) allow any hostname.

You can also control the protocol to use for the clone address. By default, the following protocols are supported: `[ 'https', 'git', 'ssh' ]`. You can change this value by adding the following line to your `config/kibana.yaml` file.  In this example, the user only wants to support the `https` protocol:

[source,yaml]
----
xpack.code.security.gitProtocolWhitelist: [ "https" ]
----

[float]
[[repo-limitations]]
==== Limitations
Consider the following limitations before cloning repositories:

- Only Git is supported. Other version control systems, such as Mercurial and SVN, are not supported.
- Your disk might not have enough space to clone repositories due to {kib} watermark settings. To update your watermark settings, contact your system administrator and request additional disk space.

include::code-install-lang-server.asciidoc[]
