Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Recursively ignoring files in the entire source tree in subversion

I am not new to Subversion, but I have up till now used Tortoise and never the commadn line. My question is, how do I ignore all files like *.o from the ENTIRE source not just the root.

For example, if I have the following files: /myfile.o /folder1/myfile2.o /folder1/folder1.1/myfile3.o /folder2/myfile4.o

If svn propedit svn:ignore "." in the root directory, and add *.o, it will ignore the myfile.o, but does not ignore /folder1/myfile2.o, /folder1/folder1.1/myfile3.o, /folder2/myfile4.o. Is there a way to add *.o in for an entire project (I cannot do it for the entire repository, which I know can be done, because this project is in a repository with many other projects)?

Please let me know if I need to clarify. Thanks!

like image 936
alanquillin Avatar asked Aug 05 '09 01:08

alanquillin


People also ask

How do I create an ignore file in svn?

Use the following command to create a list not under version control files. 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.

How do I ignore target folder in svn?

To ignore files in subversion you want to set the svn:ignore property. You can see more here http://svnbook.red-bean.com/en/1.8/svn.advanced.props.special.ignore.html about half way down. svn propset svn:ignore target .

How do I find my svn ignore list?

Use: svn pg -R svn:ignore . See Stack Overflow question How do I view all ignored patterns set with svn:ignore recursively in an SVN repository? This shows the relative path with all files ignored by SVN in a working copy of a folder structure.


3 Answers

Edit

The original answer provided below was given prior to Subversion v1.8 which introduced a way to set the default repository level ignore (called svn:global-ignores) without overriding/replacing the svn:ignore property on the root directory and every single subdirectory. Since 1.8, the best way to achieve what you would like is to invoke the following command (credit goes to TManhente):

svn propset svn:global-ignores '*.o' .

On earlier versions (and on later versions), you can still use the approach indicated in the original answer below; however, be aware that this assumes that you are okay with replacing/overwriting the svn:ignore property on each and every subdirectory... this may be fine for a smallish/newish repository but is probably not what you want if you have a large/old repository in which some subdirectories may have independent svn:ignore properties that you do not wish to overwrite.

Original answer

You can use the "-R" or "--recursive" option with "svn propset" as in the following command:

svn propset svn:ignore '*.o' . --recursive

More info

For both cases, you can use the following command for more info about svn propset:

svn help propset
like image 196
Michael Aaron Safyan Avatar answered Sep 24 '22 21:09

Michael Aaron Safyan


Just an update: Subversion 1.8.0 introduced Inherited Properties and Repository Dictated Configuration (For auto-props and ignores), which can also be used in this case.

You can set the new svn:global-ignores property in the root path. It will "only effect the subtrees rooted at the path on which the property is set".

This new property is set just like svn:ignore:

    svn propset svn:global-ignores '*.o' .

More information is available at the Subversion 1.8.0 Release Notes.

like image 43
TManhente Avatar answered Sep 24 '22 21:09

TManhente


As pointed by @hackmaster.a in a comment, the example given in the accepted answer has the side effect of wiping out all previous svn:ignore settings. Using propedit instead of propset doesn't work neither.

The right way to add multiple files recursively is putting their names in a list separated by new lines in the svn:ignore property set with svn propset svn:ignore "[LIST]" .

For example:

    svn propset svn:ignore -R "*.pkl
    > *.class
    > Thumbs.db
    > data.tmp" .

Of course the >'s are just the shell prompts.

This command will change the svn:ignore properties of the . current directory and of each of its sub-folders recursively.

like image 27
Saul Berardo Avatar answered Sep 23 '22 21:09

Saul Berardo