cp命令应该忽略一些文件 [英] cp command should ignore some files
本文介绍了cp命令应该忽略一些文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有时我需要执行以下命令
Sometimes I need to perform following command
cp -rv demo demo_bkp
但是我想忽略目录.git中的所有文件。我如何实现呢?
However I want to ignore all the files in directory .git . How do I achieve that? It takes a long time to copy .git files and I do not need those files.
推荐答案
要忽略git目录,需要很长时间来复制.git文件,我不需要这些文件。我尝试 git export
首先。
To ignore a git directory specifically, I'd try git export
first.
但是一般来说,为了复制不包括某些文件或文件夹的目录树,我建议使用 rsync
而不是 cp
。语法大体相同,但 rsync
有更多选项,其中包括排除所选文件的
But in general, to copy a directory tree excluding certain files or folders, I'd recommend using rsync
instead of cp
. The syntax is mostly the same, but rsync
has way more options, including one to exclude selected files:
rsync -rv --exclude=.git demo demo_bkp
参见例如手册页了解详情。
这篇关于cp命令应该忽略一些文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文