How do I ignore a directory with SVN?

前端 未结 23 2346
无人共我
无人共我 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:14

    Set the svn:ignore property on the parent directory:

    $ cd parentdir
    $ svn ps svn:ignore . 'cachedir'
    

    This will overwrite any current value of svn:ignore. You an edit the value with:

    $ svn pe svn:ignore .
    

    Which will open your editor. You can add multiple patterns, one per line.

    You can view the current value with:

    $ svn pg svn:ignore .
    

    If you are using a GUI there should be a menu option to do this.

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

    To expand slightly, if you're doing this with the svn command-line tool, you want to type:

    svn propedit svn:ignore path/to/dir
    

    which will open your text-editor of choice, then type '*' to ignore everything inside it, and save+quit - this will include the directory itself in svn, but ignore all the files inside it, to ignore the directory, use the path of the parent, and then type the name of the directory in the file. After saving, run an update ('svn up'), and then check in the appropriate path.

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

    If you are using the particular SVN client TortoiseSVN, then on commit, you have the option of right clicking items and selecting "Add to ignore list".

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

    TO KEEP DIRECTORIES THAT SVN WILL IGNORE:

    1. this will delete the files from the repository, but keep the directory under SVN control:

    svn delete --keep-local path/directory_to_keep/*

    1. then set to ignore the directory (and all content):

    svn propset svn:ignore "*" path/directory_to_keep

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

    Jason's answer will do the trick. However, instead of setting svn:ignore to "." on the cache directory, you may want to include "cache" in the parent directory's svn:ignore property, in case the cache directory is not always present. I do this on a number of "throwaway" folders.

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

    I had problems getting nested directories to be ignored; the top directory I wanted to ignore wouldn't show with 'svn status' but all the subdirs did. This is probably self-evident to everyone else, but I thought I'd share it:

    EXAMPLE:

    /trunk

    /trunk/cache

    /trunk/cache/subdir1

    /trunk/cache/subdir2

    cd /trunk
    svn ps svn:ignore . /cache
    cd /trunk/cache
    svn ps svn:ignore . *
    svn ci
    
    0 讨论(0)
提交回复
热议问题