Adding Only Untracked Files
 One of the commands I find incredibly useful in Git is git add -u to throw everything but untracked files into the index.  Is there an inverse of that?  In the last few months, I've often found myself in a position where I've interactively added some updates to the index and I want to add all of the untracked files to that index before I commit.  
Is there a way to add only the untracked files to the index without identifying them individually? I don't see anything obvious in the help docs, but maybe I'm missing it?
Thanks.
 It's easy with git add -i .  Type a (for "add untracked"), then * (for "all"), then q (to quit) and you're done.  
 To do it with a single command: echo -e "an*nqn"|git add -i  
 git ls-files -o --exclude-standard给出了未跟踪的文件,因此您可以执行下面的操作(或向其添加别名): 
git add $(git ls-files -o --exclude-standard)
Not exactly what you're looking for, but I've found this quite helpful:
git add -AN
 Will add all files to the index, but without their content.  Files that were untracked now behave as if they were tracked.  Their content will be displayed in git diff , and you can add then interactively with git add -p .  
上一篇: A不会在目录中添加所有已修改的文件
下一篇: 仅添加未跟踪文件
