Housekeeping

Introduced in GitLab 8.4.

Automatic housekeeping

GitLab automatically runs git gc and git repack on repositories after Git pushes. You can change how often this happens or turn it off in Admin Area > Settings > Repository (/admin/application_settings/repository).

Manual housekeeping

The housekeeping function runs repack or gc depending on the Housekeeping settings configured in Admin Area > Settings > Repository.

For example in the following scenario a git repack -d will be executed:

  • Project: pushes since GC counter (pushes_since_gc) = 10
  • Git GC period = 200
  • Full repack period = 50

When the pushes_since_gc value is 50 a repack -A -d --pack-kept-objects will run, similarly when the pushes_since_gc value is 200 a git gc will be run.

  • git gc (man page) runs a number of housekeeping tasks, such as compressing file revisions (to reduce disk space and increase performance) and removing unreachable objects which may have been created from prior invocations of git add.
  • git repack (man page) re-organize existing packs into a single, more efficient pack.

Housekeeping will also remove unreferenced LFS files from your project on the same schedule as the git gc operation, freeing up storage space for your project.

You can find this option under your project’s Settings > General > Advanced.

Housekeeping settings

How housekeeping handles pool repositories

Housekeeping for pool repositories is handled differently from standard repositories. It is ultimately performed by the Gitaly RPC FetchIntoObjectPool.

This is the current call stack by which it is invoked:

  1. Repositories::HousekeepingService#execute_gitlab_shell_gc
  2. Projects::GitGarbageCollectWorker#perform
  3. Projects::GitDeduplicationService#fetch_from_source
  4. ObjectPool#fetch
  5. ObjectPoolService#fetch
  6. Gitaly::FetchIntoObjectPoolRequest

To manually invoke it from a Rails console, if needed, you can call project.pool_repository.object_pool.fetch. This is a potentially long-running task, though Gitaly will timeout in about 8 hours.