Any difference between git add . and git add --all?
Asked Answered
E

2

36

Is there any difference between:

git add .

and

git add --all

?

Expediency answered 11/4, 2014 at 3:47 Comment(1)
possible duplicate of Difference between "git add -A" and "git add ."Roodepoortmaraisburg
P
45

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
Powerhouse answered 11/4, 2014 at 3:52 Comment(2)
Nit pick: it can't "add" the deleted files. It removes them.Involutional
@AdrianRatnapala:add the deletion of these files to the index.Golanka
A
7

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.

Aggravation answered 25/5, 2020 at 18:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.