
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:
- Add the directory, while ignoring all of the files it contains:
svn add -N [directory]
- After adding the directory enter the directory and run the following command:
svn propset svn:ignore '*.*' .
- 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
Fri, 01/13/2012 - 14:20
this is exactly what i was looking for, thanks
Mon, 03/26/2012 - 23:06
This didn't work for me. I ended up using:
svn add dirname --depth=empty
Wed, 06/13/2012 - 05:13
This doesn't cover sub directories inside the directory. For that you need svn propset svn:ignore '*' .
Tue, 06/03/2014 - 14:27
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
Sun, 02/21/2016 - 04:18
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.
Tue, 03/15/2016 - 03:32
Didn't work for me. To ignore directories I had to use
> svn propset svn:ignore '*' .
Note '*' instead of '*.*'
Fri, 04/01/2016 - 15:26
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 '*' .
Mon, 06/21/2010 - 16:43