# Other Git repository hosts

<TierCallout>
	Supported on [Enterprise](/pricing/plans/enterprise) plans.
	<user>Available via the Web app.</user>
</TierCallout>

Site admins can sync Git repositories on any Git repository host (by Git clone URL) with Sourcegraph so that users can search and navigate the repositories. Use this method only when your repository host is not named as a supported [code host](/admin/code-hosts/).

To connect generic Git host to Sourcegraph:

1. Go to **Site admin > Manage code hosts > Add repositories**
1. Select **Generic Git host**.
1. Configure the connection to generic Git host the action buttons above the text field, and additional fields can be added using `Cmd/Ctrl+Space` for auto-completion. See the [configuration documentation below](#configuration).
1. Press **Add repositories**.

## Constructing the `url` for SSH access

> NOTE: Repository access over SSH is not yet supported on [Sourcegraph Cloud](/cloud/).

If your code host serves git repositories over SSH, make sure your Sourcegraph instance can connect to your code host over SSH:

```
docker exec $CONTAINER ssh -p $PORT $USER@$HOSTNAME
```

-   $CONTAINER is the name or ID of your sourcegraph/server container
-   $PORT is the port on which your code host's git server is listening for connections
-   $USER is your user on your code host
-   $HOSTNAME is the hostname of your code host from within the sourcegraph/server container (e.g. `githost.example.com`)

Here's an example:

```
docker exec sourcegraph ssh -p 29418 admin@githost.example.com
```

The `url` field is then

```json
  "url": "ssh://$USER@$HOSTNAME:$PORT"`
```

Here's an example:

```json
  "url": "ssh://admin@githost.example.com:29418",
```

## Adding repositories

Elements of the `repos` field are the same as the repository names. For example, a repository at https://githost.example.com/admin/repos/gorilla/mux will be `"gorilla/mux"` in the `repos` field.

Repositories must be listed individually:

```json
  "repos": [
    "gorilla/mux",
    "sourcegraph/sourcegraph"
  ]
```

## Configuration

{/* <div markdown-func=jsonschemadoc jsonschemadoc:path="admin/code_hosts/other_external_service.schema.json">[View page on our docs](/admin/code-hosts/other) to see rendered content.</div> */}

### admin/code_hosts/other_external_service.schema.json

{/* SCHEMA_SYNC_START: admin/code_hosts/other_external_service.schema.json */}
{/* WARNING: This section is auto-generated during releases. Do not edit manually. */}
{/* Last updated: 2026-04-02T18:35:11Z */}
```json
{
	// A list of repositories to never mirror by name after applying repositoryPathPattern. Supports excluding by exact name ({"name": "myrepo"}) or regular expression ({"pattern": ".*secret.*"}).
	// Other example values:
	// - [
	//     {
	//       "name": "myrepo"
	//     },
	//     {
	//       "pattern": ".*secret.*"
	//     }
	//   ]
	"exclude": null,

	// SSH cipher to use when cloning via SSH. Must be a valid choice from `ssh -Q cipher`.
	"gitSSHCipher": null,

	// SSH keys to use when cloning Git repo.
	"gitSSHCredential": null,

	// Whether or not these repositories should be marked as public on Sourcegraph.com. Defaults to false.
	"makeReposPublicOnDotCom": false,

	// REQUIRED:
	"repos": null,

	// The pattern used to generate the corresponding Sourcegraph repository name for the repositories. In the pattern, the variable "{base}" is replaced with the Git clone base URL host and path, and "{repo}" is replaced with the repository path taken from the `repos` field.
	// For example, if your Git clone base URL is https://git.example.com/repos and `repos` contains the value "my/repo", then a repositoryPathPattern of "{base}/{repo}" would mean that a repository at https://git.example.com/repos/my/repo is available on Sourcegraph at https://sourcegraph.example.com/git.example.com/repos/my/repo.
	// It is important that the Sourcegraph repository name generated with this pattern be unique to this code host. If different code hosts generate repository names that collide, Sourcegraph's behavior is undefined.
	// Note: These patterns are ignored if using src-expose / src-serve.
	// Other example values:
	// - "pretty-host-name/{repo}"
	"repositoryPathPattern": "{base}/{repo}",

	// Other example values:
	// - "https://github.com/?access_token=secret"
	// - "ssh://user@host.xz:2333/"
	// - "git://host.xz:2333/"
	"url": null
}
```
{/* SCHEMA_SYNC_END: admin/code_hosts/other_external_service.schema.json */}
