macos 无法在 rsync 中排除 .DS_store

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1053853/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 06:14:28  来源:igfitidea点击:

Unable to exclude .DS_store in rsync

macosrsync

提问by Léo Léopold Hertz ??

My code

我的代码

rsync -exclude='.gitconfig' -exclude='*~' -exclude='.DS_Store' /Users/Masi/bin/ /Users/Masi/gitHub/dvorak/

I run it. It copies the .DS_Store to the destination folder although it should not.

我运行它。尽管它不应该将 .DS_Store 复制到目标文件夹。

This suggests me that the first exclusion do not work. It seems to be hard-coded in Git's default ignore -file to ignore .gitconfig.

这表明我第一次排除不起作用。它似乎在 Git 的默认 ignore -file 中硬编码以忽略 .gitconfig。

How can you avoid the coping of .DS_Store?

如何避免 .DS_Store 的应对?

回答by Gordon Davisson

It looks like you're missing a dash on your "--exclude" flags. Without it, I suspect rsync is thinking you're passing it a -e flag with the value "xclude=.DS_Store"; not at all what you want.

看起来您的“--exclude”标志上缺少破折号。没有它,我怀疑 rsync 认为您正在向它传递一个值为“xclude=.DS_Store”的 -e 标志;根本不是你想要的。

回答by dreadwail

Try the following. Place your list of items to exclude in a file

请尝试以下操作。将要排除的项目列表放在文件中

~/.rsync/exclude

One per line (wildcards acceptable).

每行一个(可以接受通配符)。

Then use the appropriate option to read the exclusions from that file:

然后使用适当的选项从该文件中读取排除项:

--exclude-from=~/.rsync/exclude

You may also wish to ask this on ServerFault, the sister site.

您可能还希望在姊妹站点 ServerFault 上询问此问题。