如何在Subversion中忽略文件?

时间:2022-03-20 17:06:35

How do I ignore files in Subversion?

如何在Subversion中忽略文件?

Also, how do I find files which are not under version control?

另外,如何查找不属于版本控制的文件?

16 个解决方案

#1


633  

(This answer has been updated to match SVN 1.8 and 1.9's behaviour)

(这个答案已经更新,以匹配SVN 1.8和1.9的行为)

You have 2 questions:

你有两个问题:

Marking files as ignored:

By "ignored file" I mean the file won't appear in lists even as "unversioned": your SVN client will pretend the file doesn't exist at all in the filesystem.

通过“忽略文件”,我的意思是文件不会出现在列表中,即使是“不版本的”:您的SVN客户端会假装文件根本不存在于文件系统中。

Ignored files are specified by a "file pattern". The syntax and format of file patterns is explained in SVN's online documentation: http://svnbook.red-bean.com/nightly/en/svn.advanced.props.special.ignore.html "File Patterns in Subversion".

被忽略的文件由“文件模式”指定。文件模式的语法和格式在SVN的在线文档中得到解释:http://svnbook.red- bean.com/nightly/en/svn.advanced.props.speci.ignore.html“Subversion中的文件模式”。

Subversion, as of version 1.8 (June 2013) and later, supports 3 different ways of specifying file patterns. Here's a summary with examples:

Subversion,在1.8版(2013年6月)和之后,支持三种不同的方式来指定文件模式。下面是一些例子:

1 - Runtime Configuration Area - global-ignores option:

  • This is a client-side only setting, so your global-ignores list won't be shared by other users, and it applies to all repos you checkout onto your computer.
  • 这是一个客户端设置,所以你的全局忽略列表不会被其他用户共享,它适用于你在你的计算机上签出的所有repos。
  • This setting is defined in your Runtime Configuration Area file:
    • Windows (file-based) - C:\Users\{you}\AppData\Roaming\Subversion\config
    • Windows(文件)——C:\Users\ {你} \ AppData \ \ Subversion \ config徘徊
    • Windows (registry-based) - Software\Tigris.org\Subversion\Config\Miscellany\global-ignores in both HKLM and HKCU.
    • 在HKLM和HKCU中,Windows(基于注册的)- Software\Tigris.org\Subversion\Config\Miscellany\global-忽略。
    • Linux/Unix - ~/.subversion/config
    • Linux / Unix - ~ / .subversion /配置
  • 这个设置是在运行时配置区域文件中定义的:Windows(基于文件的)- c:) users\(你)\AppData\ \config Windows(基于注册)-软件\Tigris.org\Subversion\ config \Miscellany\global-忽略在HKLM和HKCU。Linux / Unix - ~ / .subversion /配置

2 - The svn:ignore property, which is set on directories (not files):

  • This is stored within the repo, so other users will have the same ignore files. Similar to how .gitignore works.
  • 它存储在repo中,因此其他用户将拥有相同的忽略文件。类似于。gitignore的作品。
  • 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.
  • svn:忽略被应用到目录,并且是非递归的或继承的。匹配文件模式的父目录的任何文件或直接子目录将被排除。
  • While SVN 1.8 adds the concept of "inherited properties", the svn:ignore property itself is ignored in non-immediate descendant directories:

    SVN 1.8添加了“继承属性”的概念,SVN:忽略属性本身在非直接后代目录中被忽略:

    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).

    (因此文件。/子目录/ignoreThis并没有被忽略,即使“ignoreThis”。txt被应用于。回购根)。

  • Therefore, to apply an ignore list recursively you must use svn propset svn:ignore <filePattern> . --recursive.

    因此,如果要递归地应用一个忽略列表,您必须使用svn propset svn:忽略 。——递归。

    • 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.
    • 我开始假设您会忽略SVN中的一个文件,而键入一些类似于SVN的东西,而忽略了pathToFileToIgnore。然而,这不是SVN忽略特性的工作方式。

3- The svn:global-ignores property. Requires SVN 1.8 (June 2013):

  • This is similar to svn:ignore, except it makes use of SVN 1.8's "inherited properties" feature.
  • 这类似于svn:忽略,除非它使用svn 1.8的“继承特性”特性。
  • 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.
    • 这意味着没有必要设置svn:全局忽略的——递归标记,因为继承的忽略文件模式是自动应用的,因为它们是继承的。
  • 与svn比较:忽略,文件模式将自动应用于每个后代目录(不只是直接的子目录)。这意味着没有必要设置svn:全局忽略的——递归标记,因为继承的忽略文件模式是自动应用的,因为它们是继承的。
  • Running the same set of commands as in the previous example, but using svn:global-ignores instead:

    和前面的例子一样运行相同的命令集,但是使用svn:全局忽略:

    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!
    

For TortoiseSVN users:

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.

这整个安排让我感到困惑,因为在最初的Windows资源管理器菜单系统中使用了乌龟的术语(在他们的Windows资源管理器菜单系统中使用),这对我来说是一种误导——我不确定忽略菜单的“添加递归”、“添加*”和“添加”选项的意义。我希望这篇文章解释了忽略特性——在SVN特性中是怎样的。这就是说,我建议使用命令行来设置被忽略的文件,这样您就可以了解它是如何工作的,而不是使用GUI,并且只在您熟悉命令行之后使用GUI来操作属性。

Listing files that are ignored:

The command svn status will hide ignored files (that is, files that match an RGA global-ignores pattern, or match an immediate parent directory's svn:ignore pattern or match any ancesor directory's svn:global-ignores pattern.

命令svn状态将隐藏被忽略的文件(也就是说,匹配RGA全局忽略模式的文件,或匹配直接父目录的svn:忽略模式或匹配任何ancesor目录的svn:全局忽略模式。

Use the --no-ignore option to see those files listed. Ignored files have a status of I, then pipe the output to grep to only show lines starting with "I".

使用-no-ignore选项查看列出的文件。被忽略的文件具有I的状态,然后将输出输出到grep,以显示以“I”开头的行。

The command is:

的命令是:

svn status --no-ignore | grep "^I"

For example:

例如:

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

ta-da!

哈!

#2


67  

Use the following command to create a list not under version control files.

使用以下命令创建一个不在版本控制文件下的列表。

svn status | grep "^\?" | awk "{print \$2}" > ignoring.txt

Then edit the file to leave just the files you want actually to ignore. Then use this one to ignore the files listed in the file:

然后编辑文件,只留下你想要忽略的文件。然后使用这个来忽略文件中列出的文件:

svn propset svn:ignore -F ignoring.txt .

Note the dot at the end of the line. It tells SVN that the property is being set on the current directory.

注意这一行末尾的点。它告诉SVN,该属性被设置在当前目录中。

Delete the file:

删除文件:

rm ignoring.txt

Finally commit,

最后提交,

svn ci --message "ignoring some files"

You can then check which files are ignored via:

然后您可以检查哪些文件被忽略了:

svn proplist -v

#3


43  

If you are using TortoiseSVN, right-click on a file and then select TortoiseSVN / Add to ignore list. This will add the file/wildcard to the svn:ignore property.

如果您正在使用玳瑁,右键单击一个文件,然后选择玳瑁/ Add to ignore list。这将把文件/通配符添加到svn:忽略属性。

svn:ignore will be checked when you are checking in files, and matching files will be ignored. I have the following ignore list for a Visual Studio .NET project:

svn:当您检查文件时,忽略将被检查,而匹配的文件将被忽略。我有一个Visual Studio .NET项目的以下忽略列表:

bin obj
*.exe
*.dll
_ReSharper
*.pdb
*.suo

You can find this list in the context menu at TortoiseSVN / Properties.

您可以在玳瑁/ Properties的上下文菜单中找到这个列表。

#4


33  

You can ignore a file or directory like .gitignore. Just create a text file of list of directories/files you want to ignore and run the code below:

您可以忽略一个文件或目录,比如.gitignore。只要创建一个目录/文件列表的文本文件,您就可以忽略并运行下面的代码:

svn propset svn:ignore -F ignorelist.txt .

OR if you don't want to use a text file, you can do it like this:

或者如果你不想使用文本文件,你可以这样做:

svn propset svn:ignore "first
 second
 third" .

Source: Karsten's Blog - Set svn:ignore for multiple files from command line

源代码:Karsten的博客-设置svn:从命令行忽略多个文件。

#5


17  

I found the article .svnignore Example for Java.

我找到了Java的svnignore示例。

Example: .svnignore for Ruby on Rails,

示例:.svnignore,用于Ruby on Rails,

/log

/public/*.JPEG
/public/*.jpeg
/public/*.png
/public/*.gif

*.*~

And after that:

在那之后:

svn propset svn:ignore -F .svnignore .

Examples for .gitignore. You can use for your .svnignore

.gitignore的例子。您可以使用您的.svnignore。

https://github.com/github/gitignore

https://github.com/github/gitignore

#6


9  

When using propedit make sure not have any trailing spaces as that will cause the file to be excluded from the ignore list.

当使用propedit时,确保没有任何尾随空格,因为这会导致文件被排除在忽略列表之外。

These are inserted automatically if you've use tab-autocomplete on linux to create the file to begin with:

如果您在linux上使用了tab-autocomplete来创建文件,那么就会自动插入这些文件:

svn propset svn:ignore 'file1
file2' .

#7


8  

Another solution is:

另一个解决方案是:

svn st | awk '/^?/{print $2}' > svnignore.txt && svn propget svn:ignore >> svnignore.txt && svn propset svn:ignore -F svnignore.txt . && rm svnignore.txt

or line by line

或逐行

svn st | awk '/^?/{print $2}' > svnignore.txt 
svn propget svn:ignore >> svnignore.txt 
svn propset svn:ignore -F svnignore.txt . 
rm svnignore.txt

What it does:

它所做的:

  1. Gets the status files from the svn
  2. 从svn获取状态文件。
  3. Saves all files with ? to the file "svnignore.txt"
  4. 保存所有文件?到文件“svnignore.txt”
  5. Gets the already ignored files and appends them to the file "svnignore.txt"
  6. 获取已被忽略的文件并将其附加到文件“svnignore.txt”。
  7. Tells the svn to ignore the files in "svnignore.txt"
  8. 告诉svn忽略“svnignore.txt”中的文件。
  9. Removes the file
  10. 删除该文件

#8


6  

As nobody seems to have mentioned it...

似乎没有人提到过……

svn propedit svn:ignore .

Then edit the contents of the file to specify the patterns to ignore, exit the editor and you're all done.

然后编辑文件的内容,以指定要忽略的模式,退出编辑器,您就完成了。

#9


6  

Also, if you use Tortoise SVN you can do this:

另外,如果你使用乌龟SVN,你可以这样做:

  1. In context menu select "TortoiseSVN", then "Properties"
  2. 在上下文菜单中选择“玳瑁”,然后是“属性”
  3. In appeared window click "New", then "Advanced"
  4. 在出现的窗口中点击“New”,然后点击“Advanced”
  5. In appeared window opposite to "Property name" select or type "svn:ignore", opposite to "Property value" type desired file name or folder name or file mask (in my case it was "*/target"), click "Apply property recursively"
  6. 在与“属性名”选择或类型“svn:ignore”相反的出现窗口中,与“属性值”类型相反的文件名称或文件夹名或文件掩码(在我的例子中是“*/target”),点击“应用属性递归”
  7. Ok. Ok.
  8. 好的。好的。
  9. Commit
  10. 提交

#10


3  

You can also set a global ignore pattern in SVN's configuration file.

您还可以在SVN的配置文件中设置全局忽略模式。

#11


3  

svn status will tell you which files are not in SVN, as well as what's changed.

svn状态将告诉您哪些文件不在svn中,以及哪些文件发生了更改。

Look at the SVN properties for the ignore property.

查看忽略属性的SVN属性。

For all things SVN, the Red Book is required reading.

对于所有的事情SVN,红色的书是必需的阅读。

#12


3  

Adding a directory to subversion, and ignoring the directory contents

将目录添加到subversion中,并忽略目录内容。

svn propset svn:ignore '\*.*' .

or

svn propset svn:ignore '*' .

#13


3  

A more readable version of bkbilly's answer:

一个更可读的版本的bkbilly的回答:

svn st | awk '/^?/{print $2}' > svnignore.txt
svn propget svn:ignore >> svnignore.txt
svn propset svn:ignore -F svnignore.txt .
rm svnignore.txt

What it does:

它所做的:

  1. Gets the status files from the svn
  2. 从svn获取状态文件。
  3. Saves all files with ? to the file "svnignore.txt"
  4. 保存所有文件?到文件“svnignore.txt”
  5. Gets the already ignored files and appends them to the file "svnignore.txt"
  6. 获取已被忽略的文件并将其附加到文件“svnignore.txt”。
  7. Tells the svn to ignore the files in "svnignore.txt"
  8. 告诉svn忽略“svnignore.txt”中的文件。
  9. Removes the file
  10. 删除该文件

#14


2  

Use the command svn status on your working copy to show the status of files, files that are not yet under version control (and not ignored) will have a question mark next to them.

在工作副本上使用命令svn状态来显示文件的状态,未在版本控制下的文件(而不是被忽略)将在它们旁边有一个问号。

As for ignoring files you need to edit the svn:ignore property, read the chapter Ignoring Unversioned Items in the svnbook at http://svnbook.red-bean.com/en/1.5/svn.advanced.props.special.ignore.html. The book also describes more about using svn status.

至于忽略文件,您需要编辑svn:忽略属性,请在http://svnbook.red- bean.com/en/1.5/svn.advanced.props.speci.ignore.html中忽略svnbook中的未版本项目。该书还描述了使用svn状态的更多信息。

#15


2  

  1. cd ~/.subversion
  2. cd ~ / .subversion
  3. open config
  4. 打开配置
  5. find the line like 'global-ignores'
  6. 找到“全局忽略”这条线
  7. set ignore file type like this: global-ignores = *.o *.lo *.la *.al .libs *.so .so.[0-9] *.pyc *.pyo 88 *.rej ~ ## .#* .*.swp .DS_Store node_modules output
  8. 设置忽略文件类型:全局忽略= *。o *。罗*。*。al . lib *。所以,所以。[0 - 9]*。佩克*。巴西88 *。rej ~ ## *. *。swp .DS_Store node_modules输出

#16


1  

SVN ignore is easy to manage in TortoiseSVN. Open TortoiseSVN and right-click on file menu then select Add to ignore list.

在龟甲中,SVN的忽略是很容易的。打开玳瑁,右键点击文件菜单,然后选择Add to ignore list。

This will add the files in the svn:ignore property. When we checking in the files then those file which is matched with svn:ignore that will be ignored and will not commit.

这将在svn中添加文件:忽略属性。当我们在文件中检查时,那些与svn匹配的文件:忽略将被忽略,并且不会提交。

In Visual Studio project we have added following files to ignore:

在Visual Studio项目中,我们添加了以下文件来忽略:

bin obj
*.exe
*.dll
*.pdb
*.suo

We are managing source code on SVN of Comparetrap using this method successfully

我们用这个方法成功地管理了比较陷阱SVN的源代码。

#1


633  

(This answer has been updated to match SVN 1.8 and 1.9's behaviour)

(这个答案已经更新,以匹配SVN 1.8和1.9的行为)

You have 2 questions:

你有两个问题:

Marking files as ignored:

By "ignored file" I mean the file won't appear in lists even as "unversioned": your SVN client will pretend the file doesn't exist at all in the filesystem.

通过“忽略文件”,我的意思是文件不会出现在列表中,即使是“不版本的”:您的SVN客户端会假装文件根本不存在于文件系统中。

Ignored files are specified by a "file pattern". The syntax and format of file patterns is explained in SVN's online documentation: http://svnbook.red-bean.com/nightly/en/svn.advanced.props.special.ignore.html "File Patterns in Subversion".

被忽略的文件由“文件模式”指定。文件模式的语法和格式在SVN的在线文档中得到解释:http://svnbook.red- bean.com/nightly/en/svn.advanced.props.speci.ignore.html“Subversion中的文件模式”。

Subversion, as of version 1.8 (June 2013) and later, supports 3 different ways of specifying file patterns. Here's a summary with examples:

Subversion,在1.8版(2013年6月)和之后,支持三种不同的方式来指定文件模式。下面是一些例子:

1 - Runtime Configuration Area - global-ignores option:

  • This is a client-side only setting, so your global-ignores list won't be shared by other users, and it applies to all repos you checkout onto your computer.
  • 这是一个客户端设置,所以你的全局忽略列表不会被其他用户共享,它适用于你在你的计算机上签出的所有repos。
  • This setting is defined in your Runtime Configuration Area file:
    • Windows (file-based) - C:\Users\{you}\AppData\Roaming\Subversion\config
    • Windows(文件)——C:\Users\ {你} \ AppData \ \ Subversion \ config徘徊
    • Windows (registry-based) - Software\Tigris.org\Subversion\Config\Miscellany\global-ignores in both HKLM and HKCU.
    • 在HKLM和HKCU中,Windows(基于注册的)- Software\Tigris.org\Subversion\Config\Miscellany\global-忽略。
    • Linux/Unix - ~/.subversion/config
    • Linux / Unix - ~ / .subversion /配置
  • 这个设置是在运行时配置区域文件中定义的:Windows(基于文件的)- c:) users\(你)\AppData\ \config Windows(基于注册)-软件\Tigris.org\Subversion\ config \Miscellany\global-忽略在HKLM和HKCU。Linux / Unix - ~ / .subversion /配置

2 - The svn:ignore property, which is set on directories (not files):

  • This is stored within the repo, so other users will have the same ignore files. Similar to how .gitignore works.
  • 它存储在repo中,因此其他用户将拥有相同的忽略文件。类似于。gitignore的作品。
  • 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.
  • svn:忽略被应用到目录,并且是非递归的或继承的。匹配文件模式的父目录的任何文件或直接子目录将被排除。
  • While SVN 1.8 adds the concept of "inherited properties", the svn:ignore property itself is ignored in non-immediate descendant directories:

    SVN 1.8添加了“继承属性”的概念,SVN:忽略属性本身在非直接后代目录中被忽略:

    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).

    (因此文件。/子目录/ignoreThis并没有被忽略,即使“ignoreThis”。txt被应用于。回购根)。

  • Therefore, to apply an ignore list recursively you must use svn propset svn:ignore <filePattern> . --recursive.

    因此,如果要递归地应用一个忽略列表,您必须使用svn propset svn:忽略 。——递归。

    • 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.
    • 我开始假设您会忽略SVN中的一个文件,而键入一些类似于SVN的东西,而忽略了pathToFileToIgnore。然而,这不是SVN忽略特性的工作方式。

3- The svn:global-ignores property. Requires SVN 1.8 (June 2013):

  • This is similar to svn:ignore, except it makes use of SVN 1.8's "inherited properties" feature.
  • 这类似于svn:忽略,除非它使用svn 1.8的“继承特性”特性。
  • 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.
    • 这意味着没有必要设置svn:全局忽略的——递归标记,因为继承的忽略文件模式是自动应用的,因为它们是继承的。
  • 与svn比较:忽略,文件模式将自动应用于每个后代目录(不只是直接的子目录)。这意味着没有必要设置svn:全局忽略的——递归标记,因为继承的忽略文件模式是自动应用的,因为它们是继承的。
  • Running the same set of commands as in the previous example, but using svn:global-ignores instead:

    和前面的例子一样运行相同的命令集,但是使用svn:全局忽略:

    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!
    

For TortoiseSVN users:

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.

这整个安排让我感到困惑,因为在最初的Windows资源管理器菜单系统中使用了乌龟的术语(在他们的Windows资源管理器菜单系统中使用),这对我来说是一种误导——我不确定忽略菜单的“添加递归”、“添加*”和“添加”选项的意义。我希望这篇文章解释了忽略特性——在SVN特性中是怎样的。这就是说,我建议使用命令行来设置被忽略的文件,这样您就可以了解它是如何工作的,而不是使用GUI,并且只在您熟悉命令行之后使用GUI来操作属性。

Listing files that are ignored:

The command svn status will hide ignored files (that is, files that match an RGA global-ignores pattern, or match an immediate parent directory's svn:ignore pattern or match any ancesor directory's svn:global-ignores pattern.

命令svn状态将隐藏被忽略的文件(也就是说,匹配RGA全局忽略模式的文件,或匹配直接父目录的svn:忽略模式或匹配任何ancesor目录的svn:全局忽略模式。

Use the --no-ignore option to see those files listed. Ignored files have a status of I, then pipe the output to grep to only show lines starting with "I".

使用-no-ignore选项查看列出的文件。被忽略的文件具有I的状态,然后将输出输出到grep,以显示以“I”开头的行。

The command is:

的命令是:

svn status --no-ignore | grep "^I"

For example:

例如:

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

ta-da!

哈!

#2


67  

Use the following command to create a list not under version control files.

使用以下命令创建一个不在版本控制文件下的列表。

svn status | grep "^\?" | awk "{print \$2}" > ignoring.txt

Then edit the file to leave just the files you want actually to ignore. Then use this one to ignore the files listed in the file:

然后编辑文件,只留下你想要忽略的文件。然后使用这个来忽略文件中列出的文件:

svn propset svn:ignore -F ignoring.txt .

Note the dot at the end of the line. It tells SVN that the property is being set on the current directory.

注意这一行末尾的点。它告诉SVN,该属性被设置在当前目录中。

Delete the file:

删除文件:

rm ignoring.txt

Finally commit,

最后提交,

svn ci --message "ignoring some files"

You can then check which files are ignored via:

然后您可以检查哪些文件被忽略了:

svn proplist -v

#3


43  

If you are using TortoiseSVN, right-click on a file and then select TortoiseSVN / Add to ignore list. This will add the file/wildcard to the svn:ignore property.

如果您正在使用玳瑁,右键单击一个文件,然后选择玳瑁/ Add to ignore list。这将把文件/通配符添加到svn:忽略属性。

svn:ignore will be checked when you are checking in files, and matching files will be ignored. I have the following ignore list for a Visual Studio .NET project:

svn:当您检查文件时,忽略将被检查,而匹配的文件将被忽略。我有一个Visual Studio .NET项目的以下忽略列表:

bin obj
*.exe
*.dll
_ReSharper
*.pdb
*.suo

You can find this list in the context menu at TortoiseSVN / Properties.

您可以在玳瑁/ Properties的上下文菜单中找到这个列表。

#4


33  

You can ignore a file or directory like .gitignore. Just create a text file of list of directories/files you want to ignore and run the code below:

您可以忽略一个文件或目录,比如.gitignore。只要创建一个目录/文件列表的文本文件,您就可以忽略并运行下面的代码:

svn propset svn:ignore -F ignorelist.txt .

OR if you don't want to use a text file, you can do it like this:

或者如果你不想使用文本文件,你可以这样做:

svn propset svn:ignore "first
 second
 third" .

Source: Karsten's Blog - Set svn:ignore for multiple files from command line

源代码:Karsten的博客-设置svn:从命令行忽略多个文件。

#5


17  

I found the article .svnignore Example for Java.

我找到了Java的svnignore示例。

Example: .svnignore for Ruby on Rails,

示例:.svnignore,用于Ruby on Rails,

/log

/public/*.JPEG
/public/*.jpeg
/public/*.png
/public/*.gif

*.*~

And after that:

在那之后:

svn propset svn:ignore -F .svnignore .

Examples for .gitignore. You can use for your .svnignore

.gitignore的例子。您可以使用您的.svnignore。

https://github.com/github/gitignore

https://github.com/github/gitignore

#6


9  

When using propedit make sure not have any trailing spaces as that will cause the file to be excluded from the ignore list.

当使用propedit时,确保没有任何尾随空格,因为这会导致文件被排除在忽略列表之外。

These are inserted automatically if you've use tab-autocomplete on linux to create the file to begin with:

如果您在linux上使用了tab-autocomplete来创建文件,那么就会自动插入这些文件:

svn propset svn:ignore 'file1
file2' .

#7


8  

Another solution is:

另一个解决方案是:

svn st | awk '/^?/{print $2}' > svnignore.txt && svn propget svn:ignore >> svnignore.txt && svn propset svn:ignore -F svnignore.txt . && rm svnignore.txt

or line by line

或逐行

svn st | awk '/^?/{print $2}' > svnignore.txt 
svn propget svn:ignore >> svnignore.txt 
svn propset svn:ignore -F svnignore.txt . 
rm svnignore.txt

What it does:

它所做的:

  1. Gets the status files from the svn
  2. 从svn获取状态文件。
  3. Saves all files with ? to the file "svnignore.txt"
  4. 保存所有文件?到文件“svnignore.txt”
  5. Gets the already ignored files and appends them to the file "svnignore.txt"
  6. 获取已被忽略的文件并将其附加到文件“svnignore.txt”。
  7. Tells the svn to ignore the files in "svnignore.txt"
  8. 告诉svn忽略“svnignore.txt”中的文件。
  9. Removes the file
  10. 删除该文件

#8


6  

As nobody seems to have mentioned it...

似乎没有人提到过……

svn propedit svn:ignore .

Then edit the contents of the file to specify the patterns to ignore, exit the editor and you're all done.

然后编辑文件的内容,以指定要忽略的模式,退出编辑器,您就完成了。

#9


6  

Also, if you use Tortoise SVN you can do this:

另外,如果你使用乌龟SVN,你可以这样做:

  1. In context menu select "TortoiseSVN", then "Properties"
  2. 在上下文菜单中选择“玳瑁”,然后是“属性”
  3. In appeared window click "New", then "Advanced"
  4. 在出现的窗口中点击“New”,然后点击“Advanced”
  5. In appeared window opposite to "Property name" select or type "svn:ignore", opposite to "Property value" type desired file name or folder name or file mask (in my case it was "*/target"), click "Apply property recursively"
  6. 在与“属性名”选择或类型“svn:ignore”相反的出现窗口中,与“属性值”类型相反的文件名称或文件夹名或文件掩码(在我的例子中是“*/target”),点击“应用属性递归”
  7. Ok. Ok.
  8. 好的。好的。
  9. Commit
  10. 提交

#10


3  

You can also set a global ignore pattern in SVN's configuration file.

您还可以在SVN的配置文件中设置全局忽略模式。

#11


3  

svn status will tell you which files are not in SVN, as well as what's changed.

svn状态将告诉您哪些文件不在svn中,以及哪些文件发生了更改。

Look at the SVN properties for the ignore property.

查看忽略属性的SVN属性。

For all things SVN, the Red Book is required reading.

对于所有的事情SVN,红色的书是必需的阅读。

#12


3  

Adding a directory to subversion, and ignoring the directory contents

将目录添加到subversion中,并忽略目录内容。

svn propset svn:ignore '\*.*' .

or

svn propset svn:ignore '*' .

#13


3  

A more readable version of bkbilly's answer:

一个更可读的版本的bkbilly的回答:

svn st | awk '/^?/{print $2}' > svnignore.txt
svn propget svn:ignore >> svnignore.txt
svn propset svn:ignore -F svnignore.txt .
rm svnignore.txt

What it does:

它所做的:

  1. Gets the status files from the svn
  2. 从svn获取状态文件。
  3. Saves all files with ? to the file "svnignore.txt"
  4. 保存所有文件?到文件“svnignore.txt”
  5. Gets the already ignored files and appends them to the file "svnignore.txt"
  6. 获取已被忽略的文件并将其附加到文件“svnignore.txt”。
  7. Tells the svn to ignore the files in "svnignore.txt"
  8. 告诉svn忽略“svnignore.txt”中的文件。
  9. Removes the file
  10. 删除该文件

#14


2  

Use the command svn status on your working copy to show the status of files, files that are not yet under version control (and not ignored) will have a question mark next to them.

在工作副本上使用命令svn状态来显示文件的状态,未在版本控制下的文件(而不是被忽略)将在它们旁边有一个问号。

As for ignoring files you need to edit the svn:ignore property, read the chapter Ignoring Unversioned Items in the svnbook at http://svnbook.red-bean.com/en/1.5/svn.advanced.props.special.ignore.html. The book also describes more about using svn status.

至于忽略文件,您需要编辑svn:忽略属性,请在http://svnbook.red- bean.com/en/1.5/svn.advanced.props.speci.ignore.html中忽略svnbook中的未版本项目。该书还描述了使用svn状态的更多信息。

#15


2  

  1. cd ~/.subversion
  2. cd ~ / .subversion
  3. open config
  4. 打开配置
  5. find the line like 'global-ignores'
  6. 找到“全局忽略”这条线
  7. set ignore file type like this: global-ignores = *.o *.lo *.la *.al .libs *.so .so.[0-9] *.pyc *.pyo 88 *.rej ~ ## .#* .*.swp .DS_Store node_modules output
  8. 设置忽略文件类型:全局忽略= *。o *。罗*。*。al . lib *。所以,所以。[0 - 9]*。佩克*。巴西88 *。rej ~ ## *. *。swp .DS_Store node_modules输出

#16


1  

SVN ignore is easy to manage in TortoiseSVN. Open TortoiseSVN and right-click on file menu then select Add to ignore list.

在龟甲中,SVN的忽略是很容易的。打开玳瑁,右键点击文件菜单,然后选择Add to ignore list。

This will add the files in the svn:ignore property. When we checking in the files then those file which is matched with svn:ignore that will be ignored and will not commit.

这将在svn中添加文件:忽略属性。当我们在文件中检查时,那些与svn匹配的文件:忽略将被忽略,并且不会提交。

In Visual Studio project we have added following files to ignore:

在Visual Studio项目中,我们添加了以下文件来忽略:

bin obj
*.exe
*.dll
*.pdb
*.suo

We are managing source code on SVN of Comparetrap using this method successfully

我们用这个方法成功地管理了比较陷阱SVN的源代码。