How do I ignore files in Subversion?
Also, how do I find files which are not under version control?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
(This answer has been updated to match SVN 1.8 and 1.9’s behaviour)
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.
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".
Subversion, as of version 1.8 (June 2013) and later, supports 3 different ways of specifying file patterns. Here’s a summary with examples:
1 – Runtime Configuration Area –
global-ignoresoption:global-ignoreslist won’t be shared by other users, and it applies to all repos you checkout onto your computer.C:\Users\{you}\AppData\Roaming\Subversion\configSoftware\Tigris.org\Subversion\Config\Miscellany\global-ignoresin bothHKLMandHKCU.~/.subversion/config2 – The
svn:ignoreproperty, 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
.gitignoreworks.svn:ignoreis 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:ignoreproperty itself is ignored in non-immediate descendant directories:(So the file
./subdirectory/ignoreThisis 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.<filePattern>value is different in a child directory then the child’s value completely overrides the parents, so there is no "additive" effect.<filePattern>on the root., then you must change it with--recursiveto overwrite it on the child and descendant directories.I note that the command-line syntax is counter-intuitive.
svn ignore pathToFileToIgnore.txthowever this is not how SVN’s ignore feature works.3- The
svn:global-ignoresproperty. Requires SVN 1.8 (June 2013):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).svn:global-ignoreswith the--recursiveflag, 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-ignoresinstead: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.
Listing files that are ignored:
The command
svn statuswill hide ignored files (that is, files that match an RCAglobal-ignorespattern, or match an immediate parent directory’ssvn:ignorepattern or match any ancesor directory’ssvn:global-ignorespattern.Use the
--no-ignoreoption to see those files listed. Ignored files have a status ofI, then pipe the output togrepto only show lines starting with "I".The command is:
For example:
ta-da!