How do I ignore a directory with SVN?

前端 未结 23 2341
无人共我
无人共我 2020-11-22 16:42

I just started using SVN, and I have a cache directory that I don\'t need under source control. How can I ignore the whole directory/folder with SVN?

I am using Vers

相关标签:
23条回答
  • 2020-11-22 17:19

    Bash oneliner for multiple ignores:

    svn propset svn:ignore ".project"$'\n'".settings"$'\n'".buildpath" "yourpath"
    
    0 讨论(0)
  • 2020-11-22 17:22

    If you are using a frontend for SVN like TortoiseSVN, or some sort of IDE integration, there should also be an ignore option in the same menu are as the commit/add operation.

    0 讨论(0)
  • 2020-11-22 17:26

    Set the svn:ignore property of the parent directory:

    svn propset svn:ignore dirname .
    

    If you have multiple things to ignore, separate by newlines in the property value. In that case it's easier to edit the property value using an external editor:

    svn propedit svn:ignore .
    
    0 讨论(0)
  • 2020-11-22 17:29

    "Thank-you" svn for such a hideous, bogus and difficult way to ignore files.

    So I wrote a script svn-ignore-all:

    #!/bin/sh
    
    # svn-ignore-all
    
    # usage: 
    #   1. run svn status to see what is going on at each step 
    #   2. add or commit all files that you DO want to have in svn
    #   3. remove any random files that you don't want to svn:ignore
    #   4. run this script to svn:ignore everything marked '?' in output of `svn status`
    
    svn status |
    grep '^?' |
    sed 's/^? *//' |
    while read f; do
        d=`dirname "$f"`
        b=`basename "$f"`
        ignore=`svn propget svn:ignore "$d"`
        if [ -n "$ignore" ]; then
            ignore="$ignore
    "
        fi
        ignore="$ignore$b"
        svn propset svn:ignore "$ignore" "$d"
    done
    

    Also, to ignore specific list of files / pathnames, we can use this variant svn-ignore. I guess svn-ignore-all should really be like xargs svn-ignore.

    #!/bin/sh
    
    # svn-ignore
    
    # usage:
    #   svn-ignore file/to/ignore ...
    
    for f; do
        d=`dirname "$f"`
        b=`basename "$f"`
        ignore=`svn propget svn:ignore "$d"`
        if [ -n "$ignore" ]; then
            ignore="$ignore
    "
        fi
        ignore="$ignore$b"
        svn propset svn:ignore "$ignore" "$d"
    done
    

    One more thing: I tend to pollute my svn checkouts with many random files. When it's time to commit, I move those files into an 'old' subdirectory, and tell svn to ignore 'old'.

    0 讨论(0)
  • 2020-11-22 17:29

    Set the svn:ignore property. Most UI svn tools have a way to do this as well as the command line discussion in the link.

    0 讨论(0)
  • 2020-11-22 17:29

    Since you're using Versions it's actually really easy:

    • Browse your checked-out copy
    • Click the directory to ignore
    • In the "Ignore box on the right click Edit
    • Type *.* to ignore all files (or *.jpg for just jpg files, etc.)
    0 讨论(0)
提交回复
热议问题