Class: Git::Commands::Add Private

Inherits:
Base
  • Object
show all
Defined in:
lib/git/commands/add.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-add/2.53.0

Implements the git add command

This command updates the index using the current content found in the working tree, to prepare the content staged for the next commit.

Examples:

Basic usage

add = Git::Commands::Add.new(execution_context)
add.call('path/to/file')
add.call('file1.rb', 'file2.rb')
add.call(all: true)

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(*pathspec, **options) ⇒ Git::CommandLineResult

Execute the git add command

Parameters:

  • pathspec (Array<String>)

    files to be added to the repository (relative to the worktree root)

  • options (Hash)

    command options

Options Hash (**options):

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

    be verbose

    Alias: :v

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

    don't actually add files; show what would be added

    Alias: :n

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

    allow adding otherwise ignored files

    Alias: :f

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

    add, modify, and remove index entries to match the worktree (--all)

    Alias: :A

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

    add and modify index entries without staging removals (--no-all)

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

    add and modify files; ignore removals (--ignore-removal)

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

    include file removals (--no-ignore-removal)

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

    update tracked files only; does not add new files

    Alias: :u

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

    allow updating index entries outside the sparse-checkout cone

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

    record that the path will be added later, placing an empty entry in the index

    Alias: :N

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

    refresh stat() information in the index without adding files

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

    continue adding other files if some files cannot be added due to indexing errors

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

    check whether any given files would be ignored

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

    apply the "clean" process freshly to all tracked files to forcibly re-add them with correct line endings

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

    suppress warning when adding an embedded repository without using git submodule add

  • :chmod (String) — default: nil

    override the executable bit of added files in the index

    Value must be '+x' or '-x'

  • :pathspec_from_file (String) — default: nil

    read pathspec from the given file (use '-' for stdin)

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

    separate pathspec elements with NUL when reading from a file

Returns:

Raises:

  • (ArgumentError)

    if unsupported options are provided

  • (Git::FailedError)

    if git exits with a non-zero exit status



# File 'lib/git/commands/add.rb', line 49