svn:ignore and svn:keywords
This is just a note to myself, since I seem to keep forgetting how to do that properly. After reading the chapter in the svn-book properly and using enough [--]help I figured it out and I am scared to forget how to get it right again :-). Here is how I got it working for me.
svn:ignore
cdinto the root directory of my working copy.- Create a file .svnignore in the root of my working copy, with the following content
*.pyc
*.log
- Run
svn -R propset svn:ignore -F .svnignore .
Note the “.” at the end (that I always forgot in the beginning), that means all the directories get effected. The “-R” means that the ignore shall apply recursively, therefore you need to be in the root to have it apply to the entire tree. - Now commit all the directories, yes you have to commit them all,
svn commit * -m"set ignore"
that was also not mentioned in the svn-book, I think. But how boring would the world be without those little challenges? - And now run
svn status
and all the files that shall be ignored should be gone.
adjust that as you need it, of course.
So notice here, ignore works on the directories, I believe. That’s why you also have to use the “.” and when commiting you see that all the directories get commited.
svn:keywords
cdinto the root directory of my working copy.- Create a file .keywords in the root of my working copy, with the following content
Author
Rev
Id
- Run
svn -R propset svn:keywords -F .keywords *
Note the “*” at the end (that I also always forgot in the beginning), that tells that all the files are effected. The “-R” means that the keywords shall apply recursively, therefore you need to be in the root to have it apply to the entire tree. - SubVersion has modified all the files that contain those place-holders (like $Id$, $Rev$, etc.) and has replaced them with the proper content. Now commit all the files (now really the files have changed!), here too - you have to commit them all,
svn commit * -m"set keywords".
adjust that as you need it, of course.
So notice here, keywords works on the files. That’s why you also have to use the “*” and when commiting you see that all the files get commited.
Theresa said,
April 28, 2008 at 8:21 pm
Thanks.
Just what I was looking for. It worked for me.
oli said,
May 23, 2008 at 6:16 am
I’m probably imagining it but it seemed like the command didn’t work until -R was after propset:
svn propset -R svn:ignore -F .svnignore .
Working now - thanks!
Stefan said,
July 10, 2008 at 12:57 am
I couldn’t make it commit with a star since there were files in my root dir which are not under version control. It’s fine if you just do svn commit -m”set ignore”.
Anyway, thanks for the tip!
Willie said,
May 25, 2009 at 12:47 pm
Great! Thanks a lot for the hints.
Chris said,
June 11, 2009 at 7:59 am
How does this work for other clients using the same repository? Does each client have to do this step:
svn -R propset svn:keywords -F .keywords *
Or does it work for everyone else automatically?
Gilles said,
July 27, 2009 at 11:12 am
The problem with this approach is that you’ll have to manually reset the svn:ignore property if you later happen to create a new directory in your project tree.
Another solution is to set the global-ignores parameter in the global config file :
global-ignores = *.pyc
This parameters is global, which means cross-project which might be a problem in some cases. Anyway, this approach seems fine at least for *.pyc since such files are usually not versionned.
psj said,
July 27, 2010 at 3:16 pm
Cool! Some of the directories in my svn tree aren’t Python source dirs, and so I just wanted to set those ones to ignore pyc files. On Linux (running bash), this did the trick: set .svnignore in . as mentioned above, then
find . -name ‘*.pyc’ -exec dirname {} \; | sort | uniq | xargs svn propset svn:ignore -F .svnignore
There’s a good chance this would work on Windows using Cygwin as well.
Hope this is useful to someone.
– psj