Adding Only Untracked Files

前端 未结 11 1946
傲寒
傲寒 2020-12-07 07:04

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 la

11条回答
  •  天涯浪人
    2020-12-07 08:01

    git ls-files lists the files in the current directory. If you want to list untracked files from anywhere in the tree, this might work better:

    git ls-files -o --exclude-standard $(git rev-parse --show-toplevel)
    

    To add all untracked files in the tree:

    git ls-files -o --exclude-standard $(git rev-parse --show-toplevel) | xargs git add
    

提交回复
热议问题