金相大赛 清华:How to … Make Subversion ignore files and folders ? Hungry for Knowledge

来源:百度文库 编辑:九乡新闻网 时间:2024/04/30 00:28:42

How to … Make Subversion ignore files and folders

December 10, 2006

Excluding files from your repository
Sometimes you may have types of files or folders in your source codetree that you do not want to include in your source code repository.Everyne developing with Visual Studio will immediately know what I mean:VS automatically makes bin and obj subfolders for your project folderin which it puts the buildresults and also creates *.suo files with yourpersonal settings for a solution.

It would be convenient if we could exclude these files from ourrepository once and for all without having to manually uncheck them eachtime we update our project. Fortunatly, Subversion allows us to dothis. In fact, there are two possibilities for exclusion.

Global exclude

With the global exclude we can exclude a certain type of file ofbeing added to any repository to which a certain client connects. To dothis, you must edit the Subversion “config” file which you can find inyour local Application Data folder. A typical location for this file is:“C:\Documents and Settings\[username]\Application Data\Subversion”.

When you open this file, look for the section [miscellany]. In thissection find a line with global-ignores and remove the “#” signes infront of it (if you haven’t removed them allready). Now add the filessignatures you want to ignore.

For example, to ignore the suo files, we would write:


global-ignores = *.suo

Local exclude

The local excludes are made on folders. This means you can tellsubversion clients to ignore a specific file, type of file or folder.This is done by setting the svn:ignore property on the target folderwith the signature of the file or folder to ignore.

For example, to ignore suo files in the solution’s folder, you would perform following command in the folder of the solution:

[TargetFolder]>svn propset svn:ignore *.suo .


Do not forget the final dot, it means that the target folder is thecurrent folder. With the above command Subversion will ignore all fileswith extension “suo” in the target folder.

To ignore folders we have a similar syntax. To ignore for eample a folder “bin” in our target folder execute following command:

[TargetFolder]>svn propset svn:ignore bin .


Again, do not forget the final dot, it means that the target folder is the current folder.

To ignore multiple types of files and folders, you must have anewline delimited list of values for the svn propset command. Becausethis can not be done with the commandline (well, I do not know how to doit anyway), we create a text file with on each line the signature of afile and/or folder to ignore.
For example, we have a textfile with following content:

objbin

We save this file in the target folder and name it “ignore.txt”, and then issue the command in the target folder

[TargetFolder]>svn propset svn:ignore -F ignore.txt .


Again, do not forget the final dot, it means that the target folder isthe current folder. With the above command all folders with names objand bin in the target folder will be ignored by Subversion.

Resources

[1] svn:ignore in the Subversion documentation
[2] global-ignores in the Subversion documentation
[3] Scott Sanders :: blog :: Ignore a file in Subversion (svn ignore) (The inspiration for making this a seperate post)
[4] svn ignore property wierdness