Adding a directory to subversion, and ignoring the directory contents

Sometimes when committing things to svn you want to commit a directory, but ignore all of the files inside it. The /sites/default/files/ directory within Drupal is a perfect example. Here's how:

  1. Add the directory, while ignoring all of the files it contains:
    svn add -N [directory]
  2. After adding the directory enter the directory and run the following command:
    svn propset svn:ignore '*.*' .
  3. Commit your changes:
    svn commit -m "Added the directory and set the files within it to be ignored"

All better now...!


Hi there,

Would you happen to know how to svn add a directory that contains blank spaces in its title? For example:

svn add User accounts

where 'User accounts' is the directory title.

Many thanks and kind regards,


This doesn't cover sub directories inside the directory. For that you need svn propset svn:ignore '*' .


If I want to add a directory while this directory contains differet types of files and I want to add some special type of files how should I use add?
For example if a directory has two types of files such as .txt and .bin and I want add just onlt .txt files

This command prevents adding files in subfolder when performing an add, but it is temporary. You could also use:
svn add -N otherdir
But using svn:ignore is a "permanent" solution (until svn:ignore property is removed), which is less error-prone in large repositories, since add is recursive by default.

pumbo is right, this only ignores all files inside the directory and with an extension.
It doesn't cover the cases:
- subdirectories and all the files inside these
- files without extensions

To ignore literrally everything, you need to do:
> svn propset svn:ignore '*' .

Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <cpp>, <java>, <php>. The supported tag styles are: <foo>, [foo].
  • Web page addresses and email addresses turn into links automatically.
  • Lines and paragraphs break automatically.

About the Author

Joaquin Lippincott, CEO

Joaquin is a modern technology veteran. Throughout his career he has built successful digital strategies with a wide assortment of transformative technologies and platforms, helping clients identify a clear path for success. Over the years he has worked with industry leaders such as DC Comics, the Emmys, Intel, Technicolor, Verizon Wireless, Habitat for Humanity, Limewire, the Linux Foundation, Sony Pictures Television, Mercy Corps, and Cisco as well as numerous small businesses, advertising agencies and internet start ups. With over 14 years of experience in his field he is still as passionate about technology as ever. Joaquin is a graduate from UCLA with a degree in design and has also served on the AIGA Portland chapter board as President. Twitter: @joaquinlippinco

Ready for transformation?