如何在Subversion中忽略文件?
另外,我如何找到不在版本控制下的文件?
如何在Subversion中忽略文件?
另外,我如何找到不在版本控制下的文件?
当前回答
如果您正在使用TortoiseSVN,右键单击一个文件,然后选择TortoiseSVN /添加到忽略列表。这将把file/通配符添加到svn:ignore属性中。
Svn:签入文件时会勾选“ignore”,匹配的文件会被忽略。我有以下Visual Studio .NET项目的忽略列表:
bin obj
*.exe
*.dll
_ReSharper
*.pdb
*.suo
你可以在TortoiseSVN / Properties的上下文菜单中找到这个列表。
其他回答
(这个答案已经更新,以匹配SVN 1.8和1.9的行为)
你有两个问题:
将文件标记为忽略:
所谓“被忽略的文件”,我的意思是该文件即使是“未版本化的”也不会出现在列表中:您的SVN客户端会假装该文件在文件系统中根本不存在。
被忽略的文件由“文件模式”指定。SVN的在线文档http://svnbook.red-bean.com/nightly/en/svn.advanced.props.special.ignore.html“Subversion中的文件模式”解释了文件模式的语法和格式。
从1.8版(2013年6月)开始,Subversion支持3种不同的指定文件模式的方式。下面是一个有例子的总结:
1 -运行时配置区域-全局忽略选项:
这是一个客户端设置,所以你的全局忽略列表不会被其他用户共享,它适用于你签入到你的计算机上的所有回购。 此设置在运行时配置区域文件中定义: Windows(基于文件的)- C:\Users\{you}\AppData\Roaming\Subversion\config Windows(基于注册表)- Software\Tigris.org\Subversion\Config\Miscellany\global-忽略HKLM和HKCU。 Linux/Unix - ~/.subversion/config
2 - svn:ignore属性,设置在目录(而不是文件)上:
This is stored within the repo, so other users will have the same ignore files. Similar to how .gitignore works. svn:ignore is applied to directories and is non-recursive or inherited. Any file or immediate subdirectory of the parent directory that matches the File Pattern will be excluded. While SVN 1.8 adds the concept of "inherited properties", the svn:ignore property itself is ignored in non-immediate descendant directories: cd ~/myRepoRoot # Open an existing repo. echo "foo" > "ignoreThis.txt" # Create a file called "ignoreThis.txt". svn status # Check to see if the file is ignored or not. > ? ./ignoreThis.txt > 1 unversioned file # ...it is NOT currently ignored. svn propset svn:ignore "ignoreThis.txt" . # Apply the svn:ignore property to the "myRepoRoot" directory. svn status > 0 unversioned files # ...but now the file is ignored! cd subdirectory # now open a subdirectory. echo "foo" > "ignoreThis.txt" # create another file named "ignoreThis.txt". svn status > ? ./subdirectory/ignoreThis.txt # ...and is is NOT ignored! > 1 unversioned file (So the file ./subdirectory/ignoreThis is not ignored, even though "ignoreThis.txt" is applied on the . repo root). Therefore, to apply an ignore list recursively you must use svn propset svn:ignore <filePattern> . --recursive. This will create a copy of the property on every subdirectory. If the <filePattern> value is different in a child directory then the child's value completely overrides the parents, so there is no "additive" effect. So if you change the <filePattern> on the root ., then you must change it with --recursive to overwrite it on the child and descendant directories. I note that the command-line syntax is counter-intuitive. I started-off assuming that you would ignore a file in SVN by typing something like svn ignore pathToFileToIgnore.txt however this is not how SVN's ignore feature works.
3—svn:global-忽略属性。要求SVN 1.8(2013年6月):
This is similar to svn:ignore, except it makes use of SVN 1.8's "inherited properties" feature. Compare to svn:ignore, the file pattern is automatically applied in every descendant directory (not just immediate children). This means that is unnecessary to set svn:global-ignores with the --recursive flag, as inherited ignore file patterns are automatically applied as they're inherited. Running the same set of commands as in the previous example, but using svn:global-ignores instead: cd ~/myRepoRoot # Open an existing repo echo "foo" > "ignoreThis.txt" # Create a file called "ignoreThis.txt" svn status # Check to see if the file is ignored or not > ? ./ignoreThis.txt > 1 unversioned file # ...it is NOT currently ignored svn propset svn:global-ignores "ignoreThis.txt" . svn status > 0 unversioned files # ...but now the file is ignored! cd subdirectory # now open a subdirectory echo "foo" > "ignoreThis.txt" # create another file named "ignoreThis.txt" svn status > 0 unversioned files # the file is ignored here too!
对于TortoiseSVN用户:
This whole arrangement was confusing for me, because TortoiseSVN's terminology (as used in their Windows Explorer menu system) was initially misleading to me - I was unsure what the significance of the Ignore menu's "Add recursively", "Add *" and "Add " options. I hope this post explains how the Ignore feature ties-in to the SVN Properties feature. That said, I suggest using the command-line to set ignored files so you get a feel for how it works instead of using the GUI, and only using the GUI to manipulate properties after you're comfortable with the command-line.
列出被忽略的文件:
命令svn status将隐藏被忽略的文件(即匹配RGA全局忽略模式的文件,或匹配直接父目录的svn:忽略模式的文件,或匹配任何父目录的svn:全局忽略模式的文件)。
使用——no-ignore选项查看列出的这些文件。被忽略的文件的状态为I,然后将输出管道输送到grep,以只显示以“I”开头的行。
命令如下:
svn status --no-ignore | grep "^I"
例如:
svn status
> ? foo # An unversioned file
> M modifiedFile.txt # A versioned file that has been modified
svn status --no-ignore
> ? foo # An unversioned file
> I ignoreThis.txt # A file matching an svn:ignore pattern
> M modifiedFile.txt # A versioned file that has been modified
svn status --no-ignore | grep "^I"
> I ignoreThis.txt # A file matching an svn:ignore pattern
哈哈!
svn status将告诉您哪些文件不在svn中,以及哪些文件发生了更改。
查看SVN属性中的ignore属性。
对于SVN的所有内容,红皮书都是必读的。
我找到了这篇文章。svnignore Java示例。
例如:Ruby on Rails的.svnignore,
/log
/public/*.JPEG
/public/*.jpeg
/public/*.png
/public/*.gif
*.*~
在那之后:
svn propset svn:ignore -F .svnignore .
关于.gitignore的例子。你可以使用你的.svnignore
https://github.com/github/gitignore
什么对我有效(我使用TortoiseSVN v1.13.1):
如何在Subversion中忽略文件?
1.2 .在“文件资源管理器”中右键单击“SVN项目文件夹名称” 2.点击“SVN提交…” 3.将出现一个“提交”窗口 4.右键单击要忽略的文件夹/文件 5.点击“添加到忽略列表” 6.选择要忽略的文件夹/文件名
有几个选择(我有4个),如果你只选择文件夹/文件名,它将被添加到svn:忽略列表 如果您选择文件夹/文件名,使用(递归地),它将被添加到svn:global-忽略。这是我通常选择的,因为所有子目录都会自动继承此更改。
7.向SVN提交“属性更改”
另外,我如何找到不在版本控制下的文件?
在上述步骤3之后,点击“显示未版本化文件”,如下所示:
在TortoiseSVN中很容易管理SVN忽略。打开TortoiseSVN,右键单击文件菜单,然后选择添加到忽略列表。
这将在svn:ignore属性中添加文件。 当我们检入文件时,那些与svn:ignore匹配的文件将被忽略并且不会提交。
在Visual Studio项目中,我们添加了以下文件来忽略:
bin obj
*.exe
*.dll
*.pdb
*.suo
我们在Comparetrap的SVN上成功地使用了该方法管理源代码