Configuring a repository cache

You can configure a repository cache by creating a new appliance, connecting the repository cache to your primary appliance, and configuring replication of repository networks to the repository cache.

Note: Repository caching is currently in beta and subject to change.

About configuration for repository caching

You can configure repository caching by creating a special type of replica called a repository cache. Then, you can set data location policies that govern which repository networks are replicated to the repository cache.

Repository caching is not supported with clustering.

DNS for repository caches

The primary instance and repository cache should have different DNS names. For example, if your primary instance is at, you might decide to name a cache or

To have your CI machines fetch from the repository cache instead of the primary instance, you can use Git's url.<base>.insteadOf configuration setting. For more information, see git-config in the Git documentation.

For example, the global .gitconfig for the CI machine would include these lines.

[url ""]
	insteadOf =

Then, when told to fetch, Git will instead fetch from

Configuring a repository cache

  1. During the beta, you must enable the feature flag for repository caching on your primary GitHub Enterprise Server appliance.

    $ ghe-config cluster.cache-enabled true
  2. Set up a new GitHub Enterprise Server appliance on your desired platform. This appliance will be your repository cache. For more information, see "Setting up a GitHub Enterprise Server instance."

  3. Set an admin password that matches the password on the primary appliance and continue.

  4. Click Configure as Replica. Installation options with link to configure your new instance as a replica

  5. Under "Add new SSH key", type your SSH key. Add SSH key

  6. Click Add key.

  7. Connect to the repository cache's IP address using SSH.

    $ ssh -p 122 admin@REPLICA IP
  8. To generate a key pair for replication, use the ghe-repl-setup command with the primary appliance's IP address and copy the public key that it returns.

    $ ghe-repl-setup PRIMARY IP
  9. To add the public key to the list of authorized keys on the primary appliance, browse to https://PRIMARY-HOSTNAME/setup/settings and add the key you copied from the replica to the list.

  10. To verify the connection to the primary and enable replica mode for the repository cache, run ghe-repl-setup again.

    $ ghe-repl-setup PRIMARY IP
  11. Set a cache_location for the repository cache, replacing CACHE-LOCATION with an alphanumeric identifier, such as the region where the cache is deployed.

    $ ghe-repl-node --cache CACHE-LOCATION
  12. To start replication of the datastores, use the ghe-repl-start command.

    $ ghe-repl-start

    Warning: ghe-repl-start causes a brief outage on the primary server, during which users may see internal server errors. To provide a friendlier message, run ghe-maintenance -s on the primary node before running ghe-repl-start on the replica node to put the appliance in maintenance mode. Once replication starts, disable maintenance mode with ghe-maintenance -u. Git replication will not progress while the primary node is in maintenance mode.

  13. To verify the status of each datastore's replication channel, use the ghe-repl-status command.

    $ ghe-repl-status
  14. To enable replication of repository networks to the repository cache, set a data location policy. For more information, see "Data location policies."

Data location policies

You can control data locality by configuring data location policies for your repositories with the spokesctl cache-policy command. Data location policies determine which repository networks are replicated on which repository caches. By default, no repository networks will be replicated on any repository caches until a data location policy is configured.

You can configure a policy to replicate all networks with the --default flag. For example, this command will create a policy to replicate a single copy of every repository network to the set of repository caches whose cache_location is "kansas".

$ ghe-spokesctl cache-policy set --default 1 kansas

To configure replication for a repository network, specify the repository that is the root of the network. A repository network includes a repository and all of the repository's forks. You cannot replicate part of a network without replicating the whole network.

$ ghe-spokesctl cache-policy set <owner/repository> 1 kansas

You can override a policy that replicates all networks and exclude specific networks by specifying a replica count of zero for the network. For example, this command specifies that any repository cache in location "kansas" cannot contain any copies of that network.

$ ghe-spokesctl cache-policy set <owner/repository> 0 kansas

Replica counts greater than one in a given cache location are not supported.

Did this doc help you?

Privacy policy

Help us make these docs great!

All GitHub docs are open source. See something that's wrong or unclear? Submit a pull request.

Make a contribution

Or, learn how to contribute.