Class: Git::Commands::Clean Private

Inherits:
Base
  • Object
show all
Defined in:
lib/git/commands/clean.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Note:

arguments block audited against https://git-scm.com/docs/git-clean/2.53.0

Remove untracked files from the working tree

Cleans the working tree by recursively removing files that are not under version control. Only files unknown to Git are removed by default; with :x also removes ignored files; with :X removes only ignored files.

Examples:

Typical usage

clean = Git::Commands::Clean.new(execution_context)
clean.call(force: true)
clean.call(force: true, d: true)
clean.call(force: 2)
clean.call(dry_run: true)
clean.call(force: true, exclude: '*.log')
clean.call(force: true, X: true)
clean.call(force: true, pathspec: ['tmp/', 'build/'])

See Also:

Instance Method Summary collapse

Methods inherited from Base

allow_exit_status, arguments, #initialize, requires_git_version, skip_version_validation

Constructor Details

This class inherits a constructor from Git::Commands::Base

Instance Method Details

#call(**options) ⇒ Git::CommandLineResult

Execute the git clean command

Parameters:

  • options (Hash)

    command options

Options Hash (**options):

  • :d (Boolean, nil) — default: nil

    recurse into untracked directories

  • :force (Boolean, Integer, nil) — default: nil

    force the removal of untracked files

    When clean.requireForce is not set to false, git-clean will refuse to delete files or directories unless this option is given.

    Pass true or 1 to emit --force once. Pass 2 to emit --force --force, which also removes untracked nested git repositories (directories with a .git subdirectory).

    Alias: :f

  • :dry_run (Boolean, nil) — default: nil

    don't actually remove anything, just show what would be done

    Alias: :n

  • :quiet (Boolean, nil) — default: nil

    be quiet, only report errors

    Alias: :q

  • :exclude (String, Array<String>) — default: nil

    use the given exclude pattern in addition to the standard ignore rules

    May be specified multiple times. Alias: :e

  • :x (Boolean, nil) — default: nil

    don't use the standard ignore rules

  • :X (Boolean, nil) — default: nil

    remove only files ignored by Git

  • :pathspec (String, Array<String>) — default: nil

    limit cleaning to files matching the given pathspec(s)

  • :chdir (String, nil) — default: nil

    change to this directory before running git; not passed to the git CLI

Returns:

Raises:

  • (ArgumentError)

    if unsupported options are provided

  • (Git::FailedError)

    if git exits with a non-zero exit status



# File 'lib/git/commands/clean.rb', line 46