Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any difference between git add . and git add --all?

Tags:

git

git-add

Is there any difference between:

git add .

and

git add --all

?

like image 748
Pat Avatar asked Apr 11 '14 03:04

Pat


People also ask

Is git add same as git add -- all?

work without the difference. If you are in any subdirectory of the working directory, git add -A will add all files from the entire working directory, and git add . will add files from your current directory.

Is it possible to add all git?

The easiest way to add all files to your Git repository is to use the “git add” command followed by the “-A” option for “all”. In this case, the new (or untracked), deleted and modified files will be added to your Git staging area.

What is the difference between git add and git stage?

Staging is used to track new files in Git and update existing files. All file changes must be staged before they can be committed, and git add is the tool we use to add file contents into Git's staging area. The git add command can be used to stage one file, multiple files, or stage changes in an entire directory.


2 Answers

git add --all will add the deleted file too (removing files from index that are no longer in the working tree), while git add . does not.

For new files and files already tracked in current working tree:

git add .

For only files already tracked in current working tree:

git add -u

For new files, files already tracked in current working tree, and remove files from index that are no longer in the working tree:

git add -A

or

git add --all
like image 82
xdazz Avatar answered Oct 11 '22 12:10

xdazz


The accepted answer is valid for Git 1.x. But for Git versions from 2.0 and above, following is the difference:

git add .

Adds, modifies and removes index entries/files in the current directory and its subdirectories.

While

git add -all

And

git add -A

Adds, modifies and removes all index entries/files to match the entire working tree of the repository.

Refer Git documentation for git add here.

like image 7
Deep Avatar answered Oct 11 '22 10:10

Deep