如何让 SVN ADD 忽略二进制文件

发布于 2024-08-20 19:37:39 字数 361 浏览 7 评论 0原文

二进制文件(在 Linux 下)没有扩展名,因此我无法使用模式排除它们。因此,当我使用 SVN add 来添加目录时,我会得到类似的信息

$ svn add recursion_vector/
A         recursion_vector
A         recursion_vector/rec_vec.cxx
A         recursion_vector/rec_vec.h
A  (bin)  recursion_vector/rec_vec

Here rec_vec 是我想要排除的可执行文件。 SVN 显然将其识别为二进制。现在我可以告诉 Subversion 忽略所有二进制文件吗?

Binaries (under Linux) don't have an extension so I cannot exclude them using patterns. Thus when I use SVN add to add a directory I will get something like

$ svn add recursion_vector/
A         recursion_vector
A         recursion_vector/rec_vec.cxx
A         recursion_vector/rec_vec.h
A  (bin)  recursion_vector/rec_vec

Here rec_vec is the executable I would like to exclude. SVN obviously recognizes it as binary. Now can I tell Subversion to ignore all binary files?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

一绘本一梦想 2024-08-27 19:37:40

这有点冗长,因为它使用 find:

find [TARGET-DIRECTORY] \( -executable -type f \) -prune -o -print | xargs svn add --深度空

传递目标目录去find,find会递归该目录打印出除可执行文件之外的所有内容(\( -executable -type f \) -prune)。如果没有 -type f find 也会删除目录,因为这些目录通常设置了执行位或“搜索位”。

add 上的 --深度空 选项告诉 svn 本身不要递归文件对象,因为 find 正在处理递归。

如果您喜欢结果,可以将其放入 shell 函数中,该函数允许您传入 [TARGET-DIRECTORY] 的参数。

谢谢你,

扎卡里

This is a bit verbose because it uses find:

find [TARGET-DIRECTORY] \( -executable -type f \) -prune -o -print | xargs svn add --depth empty

Passing the target-directory to find, find will recurse the directory printing out all the contents except for executable files (\( -executable -type f \) -prune). Without -type f find would also prune directories since these usually have the execute bit or "search bit" set.

The --depth empty option on add tells svn not to itself recurse a file object, since find is handling the recursion.

If you like the result, you can put this in a shell function that would allow you to pass in arguments for [TARGET-DIRECTORY].

Thank you,

Zachary

羁拥 2024-08-27 19:37:40

您可以设置模式匹配来排除其中没有 . 的文件名吗?

Can you set up a pattern match to exclude filenames that don't have a . in them?

GRAY°灰色天空 2024-08-27 19:37:40

这并不完全是您想要的(您可能已经知道这个答案)...但无论如何:

您可以设置排除模式以根据文件名忽略某些文件。更多信息请参阅伟大的 SVN 书籍:

http://svnbook.red-bean.com/en/1.1/ch07s02.html#svn-ch-7-sect-2.3.3

除此之外,也许可以通过提交做一些事情钩子,但我没有这些经验......

祝你好运!

This is not exactly what you want (and you might already know this answer)... but anyway :

You can set exclude patterns to ignore some files based on the filenames. More info in the great SVN book :

http://svnbook.red-bean.com/en/1.1/ch07s02.html#svn-ch-7-sect-2.3.3

Other than that, it might be possible to do something with commit hooks, but I have no experience with those ...

Good luck !

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文