1

When I run git add --all *, file deletions are not being staged. The output of git status shows the deletions in red under the heading "Changes not staged for commit". It is only picking up new additions, and not deleting stuff I have removed. What should I do?

Nayuki
  • 17,911
  • 6
  • 53
  • 80
Guerrilla
  • 13,375
  • 31
  • 109
  • 210
  • Because when you write `*`, the shell expands that to all the files that exist in the current directory as of now. Git doesn't see the `*` (it sees a list of files), and never hears about the deleted files that you intended to select. – Nayuki Apr 14 '16 at 22:26
  • 1
    Thanks! That fixed it – Guerrilla Apr 14 '16 at 22:30
  • @Nayuki Could you please copy that comment into an answer? – Chris Martin Apr 14 '16 at 22:31

1 Answers1

3

When you run git add --all *, the command shell expands the * wildcard into the list of file/directory names in the current working directory. The Git program never sees the *; it receives an actual command line like git add --all foo.txt bar.jpg subdir.

It is good that you are using the --all (or -A) flag, which tells Git to stage changes to files paths that are deleted. So all you need to do is to run git add --all ., which tells Git to look at the entire current directory (and all subitems recursively), add the ones that are created/modified, and also take into consideration items that were in the index but no longer exist in the working directory.

Nayuki
  • 17,911
  • 6
  • 53
  • 80