Home Explore Blog CI



git

3rd chunk of `Documentation/git-add.adoc`
64b930f7e3bdf49dd8619b02dea6eae88b3ea015975051760000000100000fa0
 showing the unstaged content of
	such files with `git diff` and committing them with `git commit
	-a`.

`--refresh`::
	Don't add the file(s), but only refresh their stat()
	information in the index.

`--ignore-errors`::
	If some files could not be added because of errors indexing
	them, do not abort the operation, but continue adding the
	others. The command shall still exit with non-zero status.
	The configuration variable `add.ignoreErrors` can be set to
	true to make this the default behaviour.

`--ignore-missing`::
	This option can only be used together with `--dry-run`. By using
	this option the user can check if any of the given files would
	be ignored, no matter if they are already present in the work
	tree or not.

`--no-warn-embedded-repo`::
	By default, `git add` will warn when adding an embedded
	repository to the index without using `git submodule add` to
	create an entry in `.gitmodules`. This option will suppress the
	warning (e.g., if you are manually performing operations on
	submodules).

`--renormalize`::
	Apply the "clean" process freshly to all tracked files to
	forcibly add them again to the index.  This is useful after
	changing `core.autocrlf` configuration or the `text` attribute
	in order to correct files added with wrong _CRLF/LF_ line endings.
	This option implies `-u`. Lone CR characters are untouched, thus
	while a _CRLF_ cleans to _LF_, a _CRCRLF_ sequence is only partially
	cleaned to _CRLF_.

`--chmod=(+|-)x`::
	Override the executable bit of the added files.  The executable
	bit is only changed in the index, the files on disk are left
	unchanged.

`--pathspec-from-file=<file>`::
	Pathspec is passed in _<file>_ instead of commandline args. If
	_<file>_ is exactly `-` then standard input is used. Pathspec
	elements are separated by _LF_ or _CR/LF_. Pathspec elements can be
	quoted as explained for the configuration variable `core.quotePath`
	(see linkgit:git-config[1]). See also `--pathspec-file-nul` and
	global `--literal-pathspecs`.

`--pathspec-file-nul`::
	Only meaningful with `--pathspec-from-file`. Pathspec elements are
	separated with _NUL_ character and all other characters are taken
	literally (including newlines and quotes).

`--`::
	This option can be used to separate command-line options from
	the list of files, (useful when filenames might be mistaken
	for command-line options).


EXAMPLES
--------

* Adds content from all ++*.txt++ files under `Documentation` directory
  and its subdirectories:
+
------------
$ git add Documentation/\*.txt
------------
+
Note that the asterisk ++*++ is quoted from the shell in this
example; this lets the command include the files from
subdirectories of `Documentation/` directory.

* Considers adding content from all ++git-*.sh++ scripts:
+
------------
$ git add git-*.sh
------------
+
Because this example lets the shell expand the asterisk (i.e. you are
listing the files explicitly), it does not consider
`subdir/git-foo.sh`.

INTERACTIVE MODE
----------------
When the command enters the interactive mode, it shows the
output of the 'status' subcommand, and then goes into its
interactive command loop.

The command loop shows the list of subcommands available, and
gives a prompt "What now> ".  In general, when the prompt ends
with a single '>', you can pick only one of the choices given
and type return, like this:

------------
    *** Commands ***
      1: status       2: update       3: revert       4: add untracked
      5: patch        6: diff         7: quit         8: help
    What now> 1
------------

You also could say `s` or `sta` or `status` above as long as the
choice is unique.

The main command loop has 6 subcommands (plus help and quit).

status::

   This shows the change between `HEAD` and index (i.e. what will be
   committed if you say `git commit`), and between index and
   working tree files (i.e. what you could stage further before
   `git commit` using `git add`) for each path.  A sample output
   looks like this:
+
------------

Title: Git Add Command Options and Interactive Mode
Summary
The git add command provides various options for customizing its behavior, including refreshing file information, ignoring errors, and overriding executable bits, as well as an interactive mode for staging changes, which allows users to view and manage changes between the working tree, index, and HEAD.