110

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

ire_and_curses
  • 68,372
  • 23
  • 116
  • 141
Paul Tarjan
  • 48,968
  • 59
  • 172
  • 213

14 Answers14

63

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)

twin
  • 1,669
  • 13
  • 11
  • 3
    I'm a tad confused - there's `global-ignores` in the `~/.subversion/config` file, but also the *inheritable* `svn:global-ignores` property set on a directory in an SVN repo, as well as `svn:ignore` - can you provide a summary of these different options and how they compare? How does the `--recursive` flag affect them too? – Dai Mar 10 '17 at 21:29
  • 3
    I've done my own research and published my findings in this QA answer: http://stackoverflow.com/a/86052/159145 – Dai Mar 10 '17 at 22:58
  • [I've tried but failed, the `obj` folder still showed up] (https://stackoverflow.com/questions/50960188/svnglobal-ignores-not-working), can you help me to have a look on it? – Luke Jun 21 '18 at 04:10
  • Can I say "build/*" go ignore everything below build within every build folder? – Johannes Schaub - litb May 16 '19 at 11:46
  • This won't ignore folder by name recursively on svn version 1.14.0 (r1876290). – zwcloud Apr 29 '22 at 09:02
44

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
Michael Hackner
  • 8,605
  • 2
  • 27
  • 29
17

This works for me:

 svn propset --recursive svn:ignore *.zip <dir_tree_with_no_zips>
Stewart
  • 17,616
  • 8
  • 52
  • 80
  • 2
    Thanks for this, works great...By the way the only way I found to ignore both *.txt and *.pdf was to put those patterns in a file and then use the 'svn propset --file' option – wytten Sep 06 '12 at 15:19
15

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

[miscellany]
global-ignores = build dist
jspcal
  • 50,847
  • 7
  • 72
  • 76
  • I'd rather do it per-repo if I can – Paul Tarjan Jan 09 '10 at 23:23
  • 1
    hmm not sure if there's an easy way to do it per-repo, a pre-commit hook could reject certain patterns, but it's not a complete solution. svn:ignore on each parent dir works, but not recursively. you could swap out your config file with a script when working on different repos, but that's an extra step. – jspcal Jan 09 '10 at 23:31
  • 1
    What does **build dist** mean? – IgorGanapolsky Aug 16 '16 at 13:38
10

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

jsharit
  • 101
  • 1
  • 2
6

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

marian
  • 61
  • 1
  • 1
6

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 .
John Zhu
  • 1,009
  • 11
  • 11
5

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.

Blair Conrad
  • 233,004
  • 25
  • 132
  • 111
5

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/

Luccas Correa
  • 2,160
  • 2
  • 19
  • 21
2

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

jncc99
  • 19
  • 3
  • What is the **$n** here? – IgorGanapolsky Aug 16 '16 at 13:47
  • 1
    @igor Ganapolsky - The $n is the variable of the for loop. It will be set as the index for the sequence you are looping into; in this case the directory as specified by "directory" in the above example. – jncc99 Aug 25 '16 at 00:00
2
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

georg
  • 635
  • 7
  • 16
1
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'
Moin Haidar
  • 1,654
  • 1
  • 16
  • 16
  • helped me, I had problem with setting folder pattern, SVN was complianing that folder not in repo, `set EDITOR=notepad`, `svn propedit svn:ignore .`worked well... – Betlista Jan 16 '19 at 11:27
0

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.

8DH
  • 2,022
  • 23
  • 36
0

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?

martinstoeckli
  • 23,430
  • 6
  • 56
  • 87