Method: Git::Lib#add

Defined in:
lib/git/lib.rb

#add(paths = '.', options = {})

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

Update the index from the current worktree to prepare the for the next commit

Examples:

lib.add('path/to/file')
lib.add(['path/to/file1','path/to/file2'])
lib.add(:all => true)

Parameters:

  • paths (String, Array<String>) (defaults to: '.')

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

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :all (Boolean)

    Add, modify, and remove index entries to match the worktree

  • :force (Boolean)

    Allow adding otherwise ignored files



1118
1119
1120
1121
1122
1123
1124
1125
# File 'lib/git/lib.rb', line 1118

def add(paths = '.', options = {})
  args = build_args(options, ADD_OPTION_MAP)

  args << '--'
  args.concat(Array(paths))

  command('add', *args)
end