用svn管理代码,一直以来都受到一件不爽事情的困扰:
1)有些文件或文件夹不想在commit的时候看到,虽然他们是non-versioned,比如*.bak.*.class,*.scc(vss文件),目录比如bin/, classes/,还有一些是eclipse之类开发工具生成的文件
2)当错误的将以上那些不想看到的文件加入svn后,该怎么忽略它们
google了一下svn ignore,看到了些方法:
$ svn mkdir spool
$ svn propset svn:ignore '*' spool
$ svn ci -m 'Adding "spool" and ignoring its contents.'
若想创建一个文件夹,但不加入版本控制,即忽略这个文件夹:
$ mkdir spool
$ svn propset svn:ignore 'spool' .
$ svn ci -m 'Ignoring a directory called "spool".'
若已经创建了文件夹,并加入了版本控制,现在想忽略这个文件夹,但要保持文件夹的内容:
$ svn export spool spool-tmp
$ svn rm spool
$ svn ci -m 'Removing inadvertently added directory "spool".'
$ mv spool-tmp spool
$ svn propset svn:ignore 'spool' .
$ svn ci -m 'Ignoring a directory called "spool".'
我看了网上关于svn:ignore的介绍, 说对于没有加入版本控制的,可以直接设定成ignore,但不能对加入版本控制的文件和目录这么做。解决办法是,先删除再ignore, 上面的命令其实也是这个方式,只不过有导出再mv的过程。
命令行方式固然好,但我用的是tortoisesvn,界面操作更加人性化和easy。tortoisesvn下页可以类似的这么做:
1)找到这些文件,直接右键,add to ignore list, 之后可以选择by name,by extention, 选择by extention就能忽略同类文件了。
2)直接在命令模式del /s *.bak ,先把*.bak在本地工作目录删除掉,然后再commit;看需要,再将*.bak 加入ignore
There may be times when you want to keep certain files out of Subversion. Examples of these include local configuration files and temporary files like those created by vim. Fortunately, Subversion has an option to specify exclusions, via svn:ignore
. To do this, run the following in a terminal
svn propedit svn:ignore <parent directory of the files/directories to ignore>
This will open up a text editor where you can specify what to ignore, one file/directory per line. Remember that these are all relative to the parent directory you specified. Two things to note:
- The command is
svn propedit
and notsvn propset
in a normal use case. The latter command is for migrating CVS ignore files, and will produce aExplicit target required
error if you attempt to run it on a directory. - This only works for items not yet in the repository. If the file or directory was previously placed in Subversion, specifying it in the ignore file won’t have any effect.
Check out the chapter on ignoring unversioned items of the online Subversion book for more information, such as what file pattern syntax you can use in the ignore file.
看了上面两篇转载的文章,加上自己的实践总结如下:
Request:
我有一个工程,工程名为simple,采用maven进行依赖管理,在check in时我不想工程下maven产生的target目录被提交到SVN(包括目录下所有文件和目录本身)。
Solution:
1) 要被忽略的目录必须是未版本化的目录,如果已被版本化,设置svn:ignore不起作用(除非在本地删除提交后再设置或直接svn del url后再设置)。
2) 要被忽略的目录的父目录必须是已版本化的目录。
3) 命令:
a) svn pe svn:ignore simple
回车后在打开的文本编辑器里输入pattern:target
b) svn ps svn:ignore "target" simple
此命令直接在“”中加上pattern,不会打开文本编辑器。
命令的参数应该是要被忽略的目录的父目录,pattern里面写要被忽略的目录,这点我弄了很久才搞明白。
上面老外的文章里写的“The command is svn propedit
and not svn propset
in a normal use case. The latter command is for migrating CVS ignore files, and will produce a Explicit target required
error if you attempt to run it on a directory”并不正确,svn ps可以用,但是是采用 b) 形式的命令。 svn pe和svn ps都可以设置svn:ignore属性,只是usage不同而已: svn pe svn:ignore parent_dir VS svn ps svn:ignore "pattern" parent_dir. 如果两个命令的pattern相同,他们的效果是一样的。若有多个pattern,使用svn pe,一行写一个pattern
Update:
svn ps 也可以设置多个pattern:
svn ps svn:ignore "pattern1 \
pattern 2"
需要在不同pattern之间用回车隔开, 不可以是空格.用"\"分隔不同行
或者写在文件里, 然后从文件导入
svn ps svn:ignore -F svnignore dir
如果要递归设置所有目录:
svn ps -R svn:ignore -F svnignore parent_dir
如果只想设置一个maven项目下各moudle项目的根目录可以结合find命令:
find . -type d -maxdepth 1 -exec bash -c "svn ps svn:ignore -F svnignore {}" \;
相关推荐
HG,SVN忽略文件,工程管理用的。有需要的可以下载看看
向svn上提交项目工程的时候 有些不需要的文件是不必要向上提交的。
SVN忽略列表设置 介绍SVN在eclipse中的配置问题
SVN的标准目录结构:trunk、branches、tags
这是一个删除一个目录下的svn文件和目录的脚本,只需要把要删除svn相关的目录放到同级目录下即可,然后双击脚本,一键清除
SVN全局忽略样式-忽略本地编译文件
Jenkins自动化部署获取svn二级目录,Jenkins部署教程和动态获取svn路径教程
AndroidStudio在使用svn第一次提交文件时,需要忽略文件,我将第一次提交是的经验和方法总结成文档分享给大家
android studio用SVN时忽略文件。在用android studio配制SVN时,需要忽略一些文件。
HG,SVN忽略特定的文件的配置。工程管理类
清楚svn目录下生成的.svn所有文件夹
windows下批量删除SVN文件夹,很好用的
svn 清除 目录svn 清除 目录svn 清除 目录svn 清除 目录
6.2、idea svn 忽略上传的1
码云SVN提交处理空目录,自动添加keep。可选择其他默认文件
SVN目录结构说明 SVN目录结构说明 SVN目录结构说明 SVN目录结构说明
SVN项目文件夹结构指南,把里面的createdoc.txt改名为createdoc.bat后在windows下运行,所有目录结构自动生成在当前目录下,各企业的项目根据实际情况来修改,本目录适合中小型企业。
运行 kill-svn-folders.reg ,然后右击目录会出现‘删除SVN目录’的选项
常见项目svn目录结构
本文详细的介绍了svn的权限设置和本地库目录结构设计分析,难得的svn资料