开发者

SVN: Ignore some directories recursively

I don't want any directory 开发者_如何学JAVAnamed build or dist to go into my SVN no matter how deep in the tree it is.

Is this possible? In git I just put

build
dist

in my .gitignore at the root and it recursively ignores. How do I do this with svn? Please don't tell me to do a propset on every parent dir...


As of subversion 1.8, there is now the svn:global-ignores property which works like svn:ignore but recursively (so set this on your top-level directory)


svn propset takes --recursive as an option, so you can do this, with two downsides:

  1. you have to check out the entire repository (or at least all directories therein), and
  2. you have to remember to set the svn:ignore property whenever you add a new directory


This works for me:

 svn propset --recursive svn:ignore *.zip <dir_tree_with_no_zips>


add to your ~/.subversion/config or /etc/subversion/config file:

[miscellany]
global-ignores = build dist


It is possible to ignore build and dist dirs by removing the directories from version control. The trick is to use the --keep-local option to leave the directory in the working copy. For example:

svn rm dist --keep-local
svn ci -m'removed build directory from version control'

The directory will no longer be tracked by subversion but it will still be there in your working copy to hold compiler output, etc.

cheers, joe


For example the folder structure:

Project/
Project/dist/

cd Project
svn propset svn:ignore '*' dist/
svn ci -m "content of dist ignored"

It's good to do a svn delete of dist content before the ignore command, so for branches dist will be empty.

Worked for me, tested today. Here is the page explaining it a bit


In subversion 1.8 over, it is possible to set global-ignores for current repository.

svn propset svn:global-ignores build .
svn propset svn:global-ignores dist .

Also you can create a folder named .svnignore, and write conditions.

build
dist

remember one condition per line, setting build/* or dist/debug is in vain. Then do the command:

svn propset svn:global-ignores -F .svnignore .


In order to ignore all such files in all repositories, you could add a global-ignores to your per-user configuration file.

On Unix-like systems, this area appears as a directory named .subversion in the user's home directory. On Win32 systems, Subversion creates a folder named Subversion, typically inside the Application Data area of the user's profile directory

See Configuration Options

Unfortunately, there's no per-repository option to do this. It's basically per-user, or per-directory, so the multiple svn:ignores is probably the way to go, as annoying as it can be.


You first have to move to the top folder of your working copy and create a file there (say .svnignore) where you should place all the patterns that you want to be ignored, for example (for an Android project):

bin
gen
proguard
.classpath
.project
local.properties
Thumbs.db
*.apk
*.ap_
*.class
*.dex

Then you run the following command (remember that you must be at the top folder of your working copy):

svn propset svn:ignore -R -F .svnignore .

This will only work for folders and files that are not yet under version control. If you want a folder (or file) that is being versioned to start being ignored as well, remove it from version control by running the command:

svn rm --keep-local <path>

Got all this from this great article that explains it all: http://superchlorine.com/2013/08/getting-svn-to-ignore-files-and-directories/


Create a file and add your ignores into it

ingore-list:

file1 
directory1
file2
etc...

then apply the following command

for n in directory; do svn propset svn:ignore -F ignore-list $n; done

directory is name of your directory, you can sub categorize as well directory/sub-directory. Or use * to note current directory you are under.

This is assuming you are using bash as your shell


svn propset --recursive svn:ignore svn_ignore_rules .

where svn_ignore_rules is a file containing the ignore rules -- one per line

Of course you have to re-run it every time you add a new directory to your repo

svn_ignore_rules can also be considered to be checked into the repo, to be re-useable by other users having write access to the repo


cd parent_dir #the directory containing folder to be ignored recursively
svn propedit svn:ignore . #will open up svn-prop.tmp
enlist folder(s)
^X
Y
commit -m 'ignore targeted direcoty'


One way would be to add some kind of check to either the pre- or post- commit hook but it's note straight forward if you don't own the repo server.


Since there seems to be no solution for this probably common problem, i would like to share our solution. As the others already made clear, you can either use the svn:ignore property, this applies to a single directory (and therefore not for new ones), or you use global-ignores which applies to a single user (but doesn't belong to the repository).

To make life a bit easier i created a reg file named Settings.Svn.reg and added it to the root of the repository. Now everybody can doublecklick this regfile once, and has the settings done.

REGEDIT4

[HKEY_CURRENT_USER\Software\Tigris.org\Subversion\Config\miscellany]
"global-ignores"="obj *.suo *.bak *.pdb *.user *.Cache*"

I would really appreciate a solution within the SVN repository, so if somebody knows, would you care to share it?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜