When I use command git add -u .
git still doesn't update untracked files.
Works only when I specify them by path, git add -- filepath
What could it be?
Asked
Active
Viewed 5,313 times
1

c00kiemon5ter
- 16,994
- 7
- 46
- 48

sunprophit
- 1,639
- 4
- 16
- 39
2 Answers
3
untracked files cannot be updated. they are not tracked in the first place.
you need to add untracked files. to do that most commonly you'd use:
$ git add some_untracked_file
$ # or
$ git add . # add all files
$ # or
$ git add --all # similar to -A , add all again
all there doesnt mean every file, but every file that doesn't match an entry in the .gitignore file.
from the man page:
-u, --update Only match <filepattern> against already tracked files in the index rather than the working tree. That means that it will never stage new files, but that it will stage modified new contents of tracked files and that it will remove files from the index if the corresponding files in the working tree have been removed. If no <filepattern> is given, default to "."; in other words, update all tracked files in the current directory and its subdirectories. -A, --all Like -u, but match <filepattern> 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.

Community
- 1
- 1

c00kiemon5ter
- 16,994
- 7
- 46
- 48
-
1$ git add . - doesn't add untracked files. – sunprophit Apr 23 '12 at 16:08
-
1as I said `git add .` and `git add -A` both add all _untracked_ files, that do not match an entry in `.gitignore` file. You can test that easily: `mkdir test; cd test; touch a b c; git init; git add a; git commit -m "add a"; echo "b" > .gitignore; git add .gitignore; git commit -m "add ignore"; git add .; git commit -m "add c";` _b_ is ignored and not added by `git add .` or `git add -A` because it matches an entry in _.gitignore_. – c00kiemon5ter Apr 24 '12 at 01:33
2
See git manual:
-u, --update Only match against already tracked files in the index rather than he working tree. That means that it will never stage new files, but that it will stage modified new contents of tracked files and that it will remove files from the index if the corresponding files in the working tree have been removed.

user1202136
- 11,171
- 4
- 41
- 62