What git add -A -- . mean

Viewed 421

I have seen git commit in vscode console I think

git add -A -- .

I know what

git add -A

means

but what

git add -A -- .

mean ?

3 Answers

From the documentation:

--

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).

which is self-explanatory. Also, . means the present directory.

So the command effectively means to stage all files i.e. "add all tracked and untracked files (including deletions) in the the present directory and subdirectories to git index".

From git-add(1)

-A, --all, --no-ignore-removal

Update the index not only where the working tree has a file matching <pathspec> but also where the index already has an entry. This adds, modifies, and removes index entries to match the working
tree.

If no <pathspec> is given when -A option is used, all files in the entire working tree are updated (old versions of Git used to limit the update to the current directory and its subdirectories).

And that -- is used to separate arguments from <pathspec>s.

So, git add -A adds and updates the entire working tree to git's staged area, while git add -A -- . adds and updates currect directory (and subdirectories), determined with getcwd(3).

this command

git add -A --

-A, --all Like -u, but match against files in the working tree in addition to the index. That means that it will find new files as well as staging modified content and removing files that are no longer in the working tree.

AND this bellow

git add . -A --**ignore-errors**

error: open("error.txt"): Permission denied error: unable to index file error.txt

With --ignore-errors, there are still errors, but not any fatal ones.

Bellow are more detail commands from Git Documentation Page

.

-A --all --no-ignore-removal Update the index not only where the working tree has a file matching but also where the index already has an entry. This adds, modifies, and removes index entries to match the working tree.

If no is given when -A option is used, all files in the entire working tree are updated (old versions of Git used to limit the update to the current directory and its subdirectories).

--no-all --ignore-removal Update the index by adding new files that are unknown to the index and files modified in the working tree, but ignore files that have been removed from the working tree. This option is a no-op when no is used.

This option is primarily to help users who are used to older versions of Git, whose "git add …​" was a synonym for "git add --no-all …​", i.e. ignored removed files.

-N --intent-to-add Record only the fact that the path will be added later. An entry for the path is placed in the index with no content. This is useful for, among other things, 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.

--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.

-- 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).

CONFIGURATION

Related