SVN: Ignore some directories recursively

SvnVersion ControlIgnore

Svn Problem Overview


I don't want any directory named build or dist to go into my SVN no matter how deep in the tree it is.

Is this possible? In git I just put

build
dist

in my .gitignore at the root and it recursively ignores. How do I do this with svn? Please don't tell me to do a propset on every parent dir...

Svn Solutions


Solution 1 - Svn

As of subversion 1.8, there is now the svn:global-ignores property which works like svn:ignore but recursively (so set this on your top-level directory)

Solution 2 - Svn

svn propset takes --recursive as an option, so you can do this, with two downsides:

  1. you have to check out the entire repository (or at least all directories therein), and
  2. you have to remember to set the svn:ignore property whenever you add a new directory

Solution 3 - Svn

This works for me:

 svn propset --recursive svn:ignore *.zip <dir_tree_with_no_zips>

Solution 4 - Svn

add to your ~/.subversion/config or /etc/subversion/config file:

[miscellany]
global-ignores = build dist

Solution 5 - Svn

It is possible to ignore build and dist dirs by removing the directories from version control. The trick is to use the --keep-local option to leave the directory in the working copy. For example:

svn rm dist --keep-local
svn ci -m'removed build directory from version control'

The directory will no longer be tracked by subversion but it will still be there in your working copy to hold compiler output, etc.

cheers, joe

Solution 6 - Svn

For example the folder structure:

Project/
Project/dist/

cd Project
svn propset svn:ignore '*' dist/
svn ci -m "content of dist ignored"

It's good to do a svn delete of dist content before the ignore command, so for branches dist will be empty.

Worked for me, tested today. Here is the page explaining it a bit

Solution 7 - Svn

In order to ignore all such files in all repositories, you could add a global-ignores to your per-user configuration file.

> On Unix-like systems, this area > appears as a directory named > .subversion in the user's home > directory. On Win32 systems, > Subversion creates a folder named > Subversion, typically inside the > Application Data area of the user's > profile directory

See Configuration Options

Unfortunately, there's no per-repository option to do this. It's basically per-user, or per-directory, so the multiple svn:ignores is probably the way to go, as annoying as it can be.

Solution 8 - Svn

You first have to move to the top folder of your working copy and create a file there (say .svnignore) where you should place all the patterns that you want to be ignored, for example (for an Android project):

bin
gen
proguard
.classpath
.project
local.properties
Thumbs.db
*.apk
*.ap_
*.class
*.dex

Then you run the following command (remember that you must be at the top folder of your working copy):

svn propset svn:ignore -R -F .svnignore .

This will only work for folders and files that are not yet under version control. If you want a folder (or file) that is being versioned to start being ignored as well, remove it from version control by running the command:

svn rm --keep-local <path>

Got all this from this great article that explains it all: http://superchlorine.com/2013/08/getting-svn-to-ignore-files-and-directories/

Solution 9 - Svn

In subversion 1.8 over, it is possible to set global-ignores for current repository.

svn propset svn:global-ignores build .
svn propset svn:global-ignores dist .

Also you can create a folder named .svnignore, and write conditions.

build
dist

remember one condition per line, setting build/* or dist/debug is in vain. Then do the command:

svn propset svn:global-ignores -F .svnignore .

Solution 10 - Svn

Create a file and add your ignores into it

ingore-list:

file1 
directory1
file2
etc...

then apply the following command

for n in directory; do svn propset svn:ignore -F ignore-list $n; done

directory is name of your directory, you can sub categorize as well directory/sub-directory. Or use * to note current directory you are under.

This is assuming you are using bash as your shell

Solution 11 - Svn

svn propset --recursive svn:ignore svn_ignore_rules .

where svn_ignore_rules is a file containing the ignore rules -- one per line

Of course you have to re-run it every time you add a new directory to your repo

svn_ignore_rules can also be considered to be checked into the repo, to be re-useable by other users having write access to the repo

Solution 12 - Svn

cd parent_dir #the directory containing folder to be ignored recursively
svn propedit svn:ignore . #will open up svn-prop.tmp
enlist folder(s)
^X
Y
commit -m 'ignore targeted direcoty'

Solution 13 - Svn

One way would be to add some kind of check to either the pre- or post- commit hook but it's note straight forward if you don't own the repo server.

Solution 14 - Svn

Since there seems to be no solution for this probably common problem, i would like to share our solution. As the others already made clear, you can either use the svn:ignore property, this applies to a single directory (and therefore not for new ones), or you use global-ignores which applies to a single user (but doesn't belong to the repository).

To make life a bit easier i created a reg file named Settings.Svn.reg and added it to the root of the repository. Now everybody can doublecklick this regfile once, and has the settings done.

REGEDIT4

[HKEY_CURRENT_USER\Software\Tigris.org\Subversion\Config\miscellany]
"global-ignores"="obj *.suo *.bak *.pdb *.user *.Cache*"

I would really appreciate a solution within the SVN repository, so if somebody knows, would you care to share it?

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionPaul TarjanView Question on Stackoverflow
Solution 1 - SvntwinView Answer on Stackoverflow
Solution 2 - SvnMichael HacknerView Answer on Stackoverflow
Solution 3 - SvnStewartView Answer on Stackoverflow
Solution 4 - SvnjspcalView Answer on Stackoverflow
Solution 5 - SvnjsharitView Answer on Stackoverflow
Solution 6 - SvnmarianView Answer on Stackoverflow
Solution 7 - SvnBlair ConradView Answer on Stackoverflow
Solution 8 - SvnLuccas CorreaView Answer on Stackoverflow
Solution 9 - SvnJohn ZhuView Answer on Stackoverflow
Solution 10 - Svnjncc99View Answer on Stackoverflow
Solution 11 - SvngeorgView Answer on Stackoverflow
Solution 12 - SvnMoin HaidarView Answer on Stackoverflow
Solution 13 - Svn8DHView Answer on Stackoverflow
Solution 14 - SvnmartinstoeckliView Answer on Stackoverflow