Module: Git::Repository::Maintenance

Included in:
Git::Repository
Defined in:
lib/git/repository/maintenance.rb

Overview

Facade methods for repository maintenance and optimization operations

These methods pack objects, compress history, prune unreachable objects, and otherwise keep the repository in good health.

Included by Git::Repository.

Instance Method Summary collapse

Instance Method Details

#gcString

Run garbage collection to optimize and clean up the repository

Runs git gc to perform housekeeping tasks including object compression, pruning of unreachable objects, and ref packing. This is equivalent to running git gc --prune --aggressive --auto.

This method uses the fixed options prune: true, aggressive: true, auto: true (matching the 4.x behavior). No additional options are exposed.

Examples:

Run garbage collection

repo.gc

Returns:

  • (String)

    the stdout from git gc. Git writes all progress and summary output to stderr, so the returned string is typically empty. Returns String to match the 4.x public contract (Git::Lib#command returned result.stdout).

Raises:



60
61
62
# File 'lib/git/repository/maintenance.rb', line 60

def gc
  Git::Commands::Gc.new(@execution_context).call(prune: true, aggressive: true, auto: true).stdout
end

#repackString

Repack loose objects into pack files

Packs all unpacked objects and removes redundant pack files. This is equivalent to running git repack -a -d, which packs all objects into a single pack and deletes any packs that become redundant.

This method uses the fixed options a: true, d: true (matching the 4.x behavior). No additional options are exposed.

Examples:

Repack the repository

repo.repack

Returns:

  • (String)

    the stdout from git repack. Git writes all progress and summary output to stderr, so the returned string is typically empty. Returns String to match the 4.x public contract (Git::Lib#command returned result.stdout).

Raises:



37
38
39
# File 'lib/git/repository/maintenance.rb', line 37

def repack
  Git::Commands::Repack.new(@execution_context).call(a: true, d: true).stdout
end