svn - How do I ignore files in Subversion? -


how ignore files in subversion?

also, how find files not under version control?

(this answer has been updated match svn 1.8 , 1.9's behaviour)

you have 2 questions:

marking files ignored:

by "ignored file" mean file won't appear in lists "unversioned": svn client pretend file doesn't exist @ in filesystem.

ignored files specified "file pattern". syntax , format of file patterns explained in svn's online documentation: http://svnbook.red-bean.com/nightly/en/svn.advanced.props.special.ignore.html "file patterns in subversion".

subversion, of version 1.8 (june 2013) , later, supports 3 different ways of specifying file patterns. here's summary examples:

1 - runtime configuration area - global-ignores option:

  • this client-side only setting, global-ignores list won't shared other users, , applies repos checkout onto computer.
  • this setting defined in runtime configuration area file:
    • windows (file-based) - c:\users\{you}\appdata\roaming\subversion\config
    • windows (registry-based) - software\tigris.org\subversion\config\miscellany\global-ignores in both hklm , hkcu.
    • linux/unix - ~/.subversion/config

2 - svn:ignore property, set on directories (not files):

  • this stored within repo, other users have same ignore files. similar how .gitignore works.
  • svn:ignore applied directories , non-recursive or inherited. file or immediate subdirectory of parent directory matches file pattern excluded.
  • while svn 1.8 adds concept of "inherited properties", svn:ignore property ignored in non-immediate descendant directories:

    cd ~/myreporoot                             # open existing repo. echo "foo" > "ignorethis.txt"                # create file called "ignorethis.txt".  svn status                                  # check see if file ignored or not. > ?    ./ignorethis.txt > 1 unversioned file                        # ...it not ignored.  svn propset svn:ignore "ignorethis.txt" .   # apply svn:ignore property "myreporoot" directory. svn status > 0 unversioned files                       # ...but file ignored!  cd subdirectory                             # open subdirectory. echo "foo" > "ignorethis.txt"                # create file named "ignorethis.txt".  svn status > ?    ./subdirectory/ignorethis.txt        # ...and is not ignored! > 1 unversioned file 

    (so file ./subdirectory/ignorethis not ignored, though "ignorethis.txt" applied on . repo root).

  • therefore, apply ignore list recursively must use svn propset svn:ignore <filepattern> . --recursive.

    • this create copy of property on every subdirectory.
    • if <filepattern> value different in child directory child's value overrides parents, there no "additive" effect.
    • so if change <filepattern> on root ., must change --recursive overwrite on child , descendant directories.
  • i note command-line syntax counter-intuitive.

    • i started-off assuming ignore file in svn typing svn ignore pathtofiletoignore.txt not how svn's ignore feature works.

3- svn:global-ignores property. requires svn 1.8 (june 2013):

  • this similar svn:ignore, except makes use of svn 1.8's "inherited properties" feature.
  • compare svn:ignore, file pattern automatically applied in every descendant directory (not immediate children).
    • this means unnecessary set svn:global-ignores --recursive flag, inherited ignore file patterns automatically applied they're inherited.
  • running same set of commands in previous example, using svn:global-ignores instead:

    cd ~/myreporoot                                    # open existing repo echo "foo" > "ignorethis.txt"                       # create file called "ignorethis.txt" svn status                                         # check see if file ignored or not > ?    ./ignorethis.txt > 1 unversioned file                               # ...it not ignored  svn propset svn:global-ignores "ignorethis.txt" . svn status > 0 unversioned files                              # ...but file ignored!  cd subdirectory                                    # open subdirectory echo "foo" > "ignorethis.txt"                       # create file named "ignorethis.txt" svn status > 0 unversioned files                              # file ignored here too! 

for tortoisesvn users:

this whole arrangement confusing me, because tortoisesvn's terminology (as used in windows explorer menu system) misleading me - unsure significance of ignore menu's "add recursively", "add *" , "add " options. hope post explains how ignore feature ties-in svn properties feature. said, suggest using command-line set ignored files feel how works instead of using gui, , using gui manipulate properties after you're comfortable command-line.

listing files ignored:

the command svn status hide ignored files (that is, files match rga global-ignores pattern, or match immediate parent directory's svn:ignore pattern or match ancesor directory's svn:global-ignores pattern.

use --no-ignore option see files listed. ignored files have status of i, pipe output grep show lines starting "i".

the command is:

svn status --no-ignore | grep "^i" 

for example:

svn status > ? foo                             # unversioned file > m modifiedfile.txt                # versioned file has been modified  svn status --no-ignore > ? foo                             # unversioned file > ignorethis.txt                  # file matching svn:ignore pattern > m modifiedfile.txt                # versioned file has been modified  svn status --no-ignore | grep "^i" > ignorethis.txt                  # file matching svn:ignore pattern 

ta-da!


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -