Metal Toad has been building applications and cloud environments for some of the most well-known global brands for over a decade. Learn more > >

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

Comments

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,

Besnique

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

Hi,

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 20+ year technology veteran helping to lead businesses in the move to the Cloud. He frequently speaks on panels about the future of tech ranging from IoT and Machine Learning to the latest innovation in the entertainment industry.  He has helped to modernize software for industry leaders like Sony, Daimler, Intel, the Golden Globes, Siemens Wind Power, ABC, NBC, DC Comics, Warner Brothers & the Linux Foundation.

As the CEO and Founder of Metal Toad, an AWS Advanced Consulting Partner, his primary job is to "get the right people in the room".  This one responsibility is cross-functional and includes both external business development functions as well as internal delegation and leadership development.

A UCLA alumni, he also serves in the community as a Board Member for the Los Angeles Area Chamber of Commerce, the Beverly Hills Chamber of Commerce, and Stand for Children Oregon - a public education political advocacy group. As an outspoken advocate for entry-level job creation in tech he helped found the non-profit, P4TH, an organization dedicated to increasing the number of entry-level jobs in the tech industry, and is in the process of organizing an Advisory Board for the Bixel Exchange, a Los Angeles non-profit that provides almost 200 tech internships every year.

 

Ready to get started?