我想显示工作目录中除文件或目录之外的所有文件。我们在Ubuntu中为--exclude
命令提供了dir
选项。
更具体地说,我试图使用此命令将我的工作目录的文件移动到子目录:
git ls-tree -z --name-only HEAD | xargs -0 -I {} git mv {} sub_directory/
而且,在这样做时,我不想移动少量文件和目录。怎么能在Mac上实现?
答案 0 :(得分:0)
我正在使用macOS 10.12.5。我做了这些步骤:
(1)安装Homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
(2)在Linux上安装tree
命令。
brew install tree
(3)使用命令tree
并排除目录模式(例如:排除目录foo
和fuu
)。
tree -f -I "foo|fuu"
了解详情:https://unix.stackexchange.com/a/61078
在macOS类型上查看有关命令tree
的官方文档:
tree --help
您将看到许多选项,此命令的参数。
答案 1 :(得分:0)
如果要移动排除某个文件或目录的文件,建议使用rsync
命令。您还可以使用git clean
从工作树中删除未跟踪的文件。