Ignore Files and Directories in Subversion

本文介绍了如何使用Subversion (SVN) 的 svn:ignore 属性来排除特定目录或文件不被版本控制系统跟踪。通过简单的配置步骤,可以有效地管理项目中的临时文件、编译产物等不需要纳入版本控制的内容。

If you work with version control systems like subversion (svn) I'm sure you can relate to the problem of having test files show up when you try to commit changes. It is actually pretty simple to tell subversion ignore directories or specific files.

You can do this by editing the svn property called svn:ignore as follows:

svn propedit svn:ignore ./some_path

When you run that command svn will open your text editor, and this is where you can define patterns or specific files to ignore. If you place a * in the property file, it will ignore all files in the directory you specified ./some_path

*

The svn:ignore property as far as I know only supports the * as a wildcard. It doesn't support regular expressions, or anything fancy like that.

Having the wildcard is quite handy though, because you can do things like this:

*.class
test_*

Which will ignore all your files that end in .class or any file that starts with test_.

In web application development I find it handy to ignore the contents of the directory where I store uploaded images, or files.

What do you ignore?

IntelliJ IDEA 中配置 SVN 忽略特定目录,可以通过以下几种方式进行设置,具体取决于你使用的 IntelliJ IDEA 版本以及你希望忽略的文件或目录类型。以下方法适用于较新版本(如 2020.x 及以上)以及旧版本(如 2019.3.1)[^1]。 ### 通过 `.svnignore` 文件忽略目录 SubversionSVN)本身支持通过 `.svnignore` 文件来定义忽略规则。你可以在项目的根目录或特定子目录中创建或编辑 `.svnignore` 文件,并添加需要忽略的目录或文件名。 例如,要忽略 `logs` 和 `temp` 目录,可以在 `.svnignore` 文件中添加以下内容: ``` logs/ temp/ ``` 保存文件后,在终端中运行以下命令以确保规则生效: ```bash svn propset svn:ignore -F .svnignore . svn commit -m "Add ignore rules for logs and temp directories" ``` ### 通过 IntelliJ IDEA 设置忽略目录 在 IntelliJ IDEA 中,也可以通过图形界面设置忽略特定目录或文件: 1. 打开 **Settings/Preferences**(Windows 上是 `File > Settings`,Mac 上是 `IntelliJ IDEA > Preferences`)。 2. 导航到 **Version Control > Ignored Files**。 3. 点击 **+** 按钮,添加你希望忽略的目录或文件。 4. 选择忽略类型: - **Unversioned**:仅忽略未版本控制的文件。 - **Silently**:忽略所有匹配的更改,包括版本控制的文件。 - **With Confirmation**:在提交时提示确认忽略。 ### 通过 `.idea/.svnignore` 文件(适用于 2019.3.1 版本) 在 IntelliJ IDEA 2019.3.1 中,可以通过 `.idea/.svnignore` 文件来定义忽略规则。你可以在项目根目录下的 `.idea` 文件夹中创建或编辑 `.svnignore` 文件,并添加需要忽略的目录或文件名: ``` *.log /temp/ ``` 保存后,这些规则将在 SVN 提交时生效。 ### 示例:忽略 `target/` 和 `.iml` 文件 如果你使用的是 Maven 项目,通常需要忽略 `target/` 目录和 `.iml` 文件,可以在 `.svnignore` 文件中添加如下内容: ``` target/ *.iml ``` 然后执行以下命令更新 SVN 属性: ```bash svn propset svn:ignore -F .svnignore . svn commit -m "Ignore target and .iml files" ``` ### 注意事项 - 确保在提交之前设置好忽略规则,以避免意外提交不需要的文件。 - 如果某些文件已经提交到 SVN 仓库,`.svnignore` 文件不会自动将其从仓库中移除,需要手动执行 `svn delete` 命令。 - 在团队协作中,建议将 `.svnignore` 文件提交到仓库,以确保所有开发者使用相同的忽略规则。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值