Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between $ git add --all vs $ git add *?

Tags:

git

When I do $ git add * sometimes I realized that git doesn't add the deleted files to the stage and I need to indicate manually if remove or add it, but I can't figure out what's the difference with $ git add --all. So if the asterisk () indicates 'everything' (), why git doesn't add all like **--all flag'?

I checked the git documentation git-add and some Difference between “git add -A” and “git add .” but doesn't specify the case when using asterisk.

Also the first answer in git add * (asterisk) vs git add . (period) indicates:

add * means add all files in the current directory, except for files, whose name begin with a dot. This is your shell functionality, actually, Git only receives a list of files.

So it means that is identically * and --all?

Thanks

like image 669
PlainOldProgrammer Avatar asked Nov 13 '15 04:11

PlainOldProgrammer


People also ask

What is difference between git add and git add -- all?

In short, we can say that “git add” is used to stage a specific file while “git add -A” stages all the modified files at once.

What is git add -- all?

Enter git add --all at the command line prompt in your local project directory to add the files or changes to the repository. Enter git status to see the changes to be committed. Enter git commit -m '<commit_message>' at the command line to commit new files/changes to the local repository.

Does git add add everything?

Add All Files using Git Add. 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.


1 Answers

The difference is:

  • git add -A adds everything from the top git repo folder.
    It operates on the entire working tree, and not just on the current path.
  • git add * adds the files (as expanded by the shell, without dotfiles) from the current folder.
    It operates starting from the current path.
like image 82
VonC Avatar answered Oct 06 '22 05:10

VonC