简体   繁体   English

svn忽略设置操作方法?

[英]svn ignore setting how-to?

I am now trying to set ignore file list to svn. 我现在正在尝试将忽略文件列表设置为svn。 I did try this way. 我确实尝试过这种方式。

svn propedit svn:ignore .
.project
.cproject
tags
cscope.files
cscope.out
SICR2000_CPU_Ver0.04.25.tgz

And with these settings, my svn status prints out like shown below. 通过这些设置,我的svn状态打印出如下所示。

svn status
M      .
M       .cproject
~       tags
M       .project

Look, first 3 files from my ignore settings are not ignored! 看,我的忽略设置中的前3个文件不会被忽略!

.project
.cproject
tags

I'd like to know why these three files are not ignored when I svn status . 我想知道为什么在我svn状态时不会忽略这三个文件。 How can I set these three files ignored? 如何设置这三个文件被忽略?

Journeyer Journeyer

You can't ignore files that already exist in the repository. 您不能忽略存储库中已存在的文件。

Ignoring is mainly used when you create files that you don't want to accidentally put into your repository. 忽略主要用于创建不希望意外放入存储库的文件。 For example, in C, you create *.o files from *.c , or in Java, you create *.class files from *.java . 例如,在C中,您可以从*.c或Java中创建*.o文件,从*.java创建*.class文件。 If I set my work directory up to ignore these file, the version control system won't report on them. 如果我将工作目录设置为忽略这些文件,则版本控制系统将不会报告它们。

Imagine this setup: 想象一下这个设置:

$ svn st
M  foo.txt
M  bar.txt
?  ignore.me

The file ignore.me is reported. 报告文件ignore.me Now, I'm going to ignore it: 现在,我将忽略它:

$ svn ps svn:ignore 'ignore.me' .
$ svn st
 M .
M  foo.txt
M  bar.txt

Notice that ignore.me is no longer showing up when I take a status. 请注意,当我获取状态时, ignore.me不再显示。 However, I can add it: 但是,我可以添加它:

$ svn add ignore.me
 M .
M  foo.txt
M  bar.txt
A  ignore.me

Notice it is showing up in my status report. 请注意,它显示在我的状态报告中。 That's because it's now part of the repository (or will be once I do a commit). 那是因为它现在是存储库的一部分(或者一旦我做了提交)。 We use Java and all of our build stuff goes under a directory called target . 我们使用Java,所有构建的东西都在一个名为target的目录下。 We also have a build.properties file that can be setup by the developers to change the way the build works. 我们还有一个build.properties文件,开发人员可以设置它来改变构建的工作方式。 However, this is a file that's used on a per-developer basis, and should not be checked into our repository. 但是,这是一个基于每个开发人员使用的文件,不应该检入我们的存储库。

Therefore, I add both build.properties and target to my svn:ignore . 因此,我将build.propertiestarget添加到我的svn:ignore Sometimes I will remove the .project and .classpath from a project and then ignore those too. 有时我会从项目中删除.project.classpath ,然后ignore它们。 These are Eclipse files that should be setup on a per developer basis. 这些是应该基于每个开发人员设置的Eclipse文件。

If you need to prevent people from checking in changes to particular files, or even to add particular files (that is not only ignore, but prevent anyone from purposefully adding the files), you need a pre-commit hook . 如果您需要阻止人们检查特定文件的更改,甚至添加特定文件(这不仅是忽略,而是阻止任何人有意添加文件),您需要预先提交挂钩 This will help enforce your setup and prevent users from making changes they shouldn't make. 这有助于强制执行您的设置并阻止用户进行不应进行的更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM