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

  1. cd into the root directory of my working copy.
  2. Create a file .svnignore in the root of my working copy, with the following content
    *.pyc
    *.log
  3. adjust that as you need it, of course.

  4. 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.
  5. 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?
  6. And now run
    svn status
    and all the files that shall be ignored should be gone.

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

  1. cd into the root directory of my working copy.
  2. Create a file .keywords in the root of my working copy, with the following content
    Author
    Rev
    Id
  3. adjust that as you need it, of course.

  4. 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.
  5. 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".

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.

13 Comments »

  1. Theresa said,

    April 28, 2008 at 8:21 pm

    Thanks. :) Just what I was looking for. It worked for me.

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

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

  4. Willie said,

    May 25, 2009 at 12:47 pm

    Great! Thanks a lot for the hints.

  5. 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?

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

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

  8. straffer Bauch said,

    September 22, 2012 at 1:40 am

    This design is spectacular! You certainly know how to keep a reader
    amused. Between your wit and your videos, I was almost
    moved to start my own blog (well, almost…HaHa!) Great job.

    I really enjoyed what you had to say, and more than that, how you presented it.
    Too cool!

  9. {industriesauger {im test|auf dem prüfstand}|die {wesentlichen |}{vorteile|nachteile} von industriesauger|industriesauger {im überblick|in der übersicht|auf einen blick}|{informationen|wissenswertes|artikel} über industriesauger|sind industriesauger { said,

    September 23, 2012 at 8:45 am

    That is very interesting, You are a very skilled blogger.
    I have joined your rss feed and look forward to in search of extra of your wonderful post.
    Also, I have shared your website in my social networks

  10. {Rohrreiniger {Im Test|Auf Dem PrüFstand}|Die {Wesentlichen |}{Vorteile|Nachteile} Von Rohrreiniger|Rohrreiniger {Im üBerblick|In Der üBersicht|Auf Einen Blick}|{Informationen|Wissenswertes|Artikel} üBer Rohrreiniger|Sind Rohrreiniger {Sinnvoll|Notwen said,

    September 23, 2012 at 8:53 am

    I drop a comment when I appreciate a article on a website or I have something to valuable to contribute to
    the discussion. It is triggered by the sincerness communicated in the article I looked at.
    And on this article Pythoneer » svn:ignore and svn:keywords. I was actually excited enough
    to write a commenta response :) I actually do have a couple of
    questions for you if you usually do not mind. Could it be simply me or does it give the impression like a few of
    these responses come across like they are coming from brain dead people?
    :-P And, if you are posting at additional social sites, I would like
    to follow anything fresh you have to post.
    Could you list the complete urls of all your communal pages
    like your twitter feed, Facebook page or linkedin profile?

  11. http://newmobilehomesforsale.Org/ said,

    November 19, 2012 at 11:45 am

    Hello there! I know this is kinda off topic but I was wondering if you knew where I could get a captcha plugin for
    my comment form? I’m using the same blog platform as yours and I’m having difficulty finding one?
    Thanks a lot!

  12. Ronald Castel said,

    April 3, 2013 at 11:59 am

    You could definitely see your enthusiasm in the paintings you write. The arena hopes for even more passionate writers such as you who aren’t afraid to mention how they believe. Always follow your heart. “A second wife is hateful to the

  13. coupon said,

    May 5, 2013 at 9:57 pm

    And things unknown proposed as things forgot. by Alexander Pope.

RSS feed for comments on this post · TrackBack URL

Leave a Comment