I am new to SVN, and I want to ignore a directory recursively, like in Git. I have a directory, sample
, which I want to ignore recursively.
>svn status
sample/first/1.jpg
sample/second/2.jpg
sample/third/3.jpg
I have tried:
svn ps svn:ignore "*" .
(under the sample
directory) ~/.subversion/config
as global-ignores = sample
. But still it shows the same result when I run svn status
:
>svn status
sample/first/1.jpg
sample/second/2.jpg
sample/third/3.jpg
How can I recursively ignore a directory in SVN?
svn -R propset svn:ignore . -F somefile.txt
somefile.txt是一个包含你想要递归设置的所有svn ignore模式的文件。
If you want to ignore the directory samples
and all the content within, you must set svn:ignore
in the directory containing the samples
directory. You did it within samples
itself. Please note two things:
svn:ignore
affects only unversions files. This means, that files and directories already known to SVN will still show up.
svn:ignore
settings are not cumulative or recursive. If you want to ignore only the *.jpg files in you treee, you have to set svn:ignore
to *.jpg
in each directory.
Please note, that the command svn propset
has an -R
(aka. recursive) option, which might help. But keep in mind, that propset
is not propadd
. This is of course only a concern if you want to set different values in the tree.
There is a new SVN property to do this from SVN 1.8 onwards. See the bottom of this page from the SVN book :
svn:global-ignores
It applies to the folder you set it on and everything underneath, and you do not need to specify recursive. For example, to set on the current directory:
svn propset svn:global-ignores "bin obj" .
From http://svnbook.red-bean.com/en/1.5/svn-book.html#svn.advanced.props.special.ignore :
"The patterns found in the svn:ignore property apply only to the directory on which that property is set, and not to any of its subdirectories."
[...]
"Once an object is under Subversion's control, the ignore pattern mechanisms no longer apply to it. In other words, don't expect Subversion to avoid committing changes you've made to a versioned file simply because that file's name matches an ignore pattern—Subversion always notices all of its versioned objects."
You could use the -R flag but that only applies the property recursivly - it doesn't change the properties effect so won't apply to any new directories created.
Also I suggest using propedit instead of ps as it allows mulitline edit, otherwise it's tricky to deal with more than one ignore pattern.
For those on *nix:
Although the documentation implies that ~.subversion/config
should already have the default configuration in it, mine (SVN 1.6.17 on Ubuntu) was empty.
Here's the format I finally got to work (this is the entire file), includes the default settings and I've added *.ignore on the end:
[Miscellany]
global-ignores=*.o *.lo *.la #*# .*.rej *.rej .*~ *~ .#* .DS_Store *.ignore
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.