当我使用命令git add -u .
git 仍然不会更新未跟踪的文件。
仅当我通过路径指定它们时才有效,git add -- filepath
它可能是什么?
问问题
4758 次
2 回答
3
无法更新未跟踪的文件。他们一开始就没有被跟踪。
您需要添加未跟踪的文件。为此,您最常使用:
$ git add some_untracked_file
$ # or
$ git add . # add all files
$ # or
$ git add --all # similar to -A , add all again
all并不意味着每个文件,而是每个与.gitignore文件中的条目不匹配的文件。
从手册页:
-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.
于 2012-04-23T14:00:45.593 回答
2
参见 git 手册:
-u, --update 只匹配索引中已经跟踪的文件而不是工作树。这意味着它永远不会暂存新文件,但它将暂存已修改的跟踪文件的新内容,并且如果工作树中的相应文件已被删除,它将从索引中删除文件。
于 2012-04-23T14:00:22.587 回答