How do I ignore a directory with SVN?

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

    After losing a lot of time looking for how to do this simple activity, I decided to post it was not hard to find a decent explanation.

    First let the sample structure

    $ svn st ? project/trunk/target ? project/trunk/myfile.x

    1 – first configure the editor,in mycase vim export SVN_EDITOR=vim

    2 – “svn propedit svn:ignore project/trunk/” will open a new file and you can add your files and subdirectory in us case type “target” save and close file and works

    $ svn st ? project/trunk/myfile.x

    thanks.

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

    The command to ignore multiple entries is a little tricky and requires backslashes.

    svn propset svn:ignore "cache\
    tmp\
    null\
    and_so_on" .
    

    This command will ignore anything named cache, tmp, null, and and_so_on in the current directory.

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

    Since I spent a while trying to get this to work, it should be noted that if the files already exist in SVN, you need to svn delete them, and then edit the svn:ignore property.

    I know that seems obvious, but they kept showing up as ? in my svn status list, when I thought it would just ignore them locally.

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

    Remove it first...

    If your directory foo is already under version control, remove it first with:

    svn rm --keep-local foo
    

    ...then ignore:

    svn propset svn:ignore foo .
    
    0 讨论(0)
  • 2020-11-22 17:11

    If your project directory is named /Project, and your cache directory is named /Project/Cache, then you need to set a subversion property on /Project. The property name should be "svn:ignore" and the property value should be "Cache".

    Refer to this page in the Subversion manual for more on properties.

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

    Thanks for all the contributions above. I would just like to share some additional information from my experiences while ignoring files.


    When the folders are already under revision control

    After svn import and svn co the files, what we usually do for the first time.

    All runtime cache, attachments folders will be under version control. so, before svn ps svn:ignore, we need to delete it from the repository.

    With SVN version 1.5 above we can use svn del --keep-local your_folder, but for an earlier version, my solution is:

    1. svn export a clean copy of your folders (without .svn hidden folder)
    2. svn del the local and repository,
    3. svn ci
    4. Copy back the folders
    5. Do svn st and confirm the folders are flagged as '?'
    6. Now we can do svn ps according to the solutions

    When we need more than one folder to be ignored

    • In one directory I have two folders that need to be set as svn:ignore
    • If we set one, the other will be removed.
    • Then we wonder we need svn pe

    svn pe will need to edit the text file, and you can use this command if required to set your text editor using vi:

    export SVN_EDITOR=vi
    
    1. With "o" you can open a new line
    2. Type in all the folder names you want to ignore
    3. Hit 'esc' key to escape from edit mode
    4. Type ":wq" then hit Enter to save and quit

    The file looks something simply like this:

    runtime
    cache
    attachments
    assets
    
    0 讨论(0)
提交回复
热议问题