Adding a whole complex directory hierarchy is an unusual thing to do (and certainly not something that happens as part of the usual git development workflow), so git doesn't have a special feature for it. You can always use an external tool to assemble a list of files you want to add and feed that list to git add
, e.g. to only add the files in the current directory non-recursively, do
git add $(find . -type f -maxdepth 1)
Alternatively, you could use
git ls-files --others --directory > file-list
to create a list of untracked files in your current directory, and edit it in an editor to remove everything you don't want to add. (Make sure to remove file-list
itself.) You can then use
git add $(cat file-list)
to add the files and directories in the edited list. (Directories you leave in will still be added recursively).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…