179

What is the best (or as good as possible) general SVN ignore pattern to use?

There are a number of different IDE, editor, compiler, plug-in, platform, etc. specific files and some file types that "overlap" (i.e. desirable for some types projects and not for others).

There are however, a large number of file types that you just never want included in source control automatically regardless the specifics of your development environment.

The answer to this question would serve as a good starting point for any project - only requiring them to add the few environment specific items they need. It could be adapted for other Version Control Systems (VCS) as well.

John Millikin
  • 197,344
  • 39
  • 212
  • 226
Zach Burlingame
  • 13,476
  • 14
  • 56
  • 65
  • Hello Zach, I've been reading this post of yours: http://www.zachburlingame.com/2011/03/installing-mercurial-and-hosting-repositories-with-centos/ and I have a couple of questions..Is there a way to reach you with this? Thanks for your time...P.S: Couldn't find any other way to reach you except through this comment here, sorry for the annoyance – Brams Jul 09 '14 at 08:56

17 Answers17

196

I'll add my own two cents to this question:

I use the following SVN ignore pattern with TortoiseSVN and Subversion CLI for native C++, C#/VB.NET, and PERL projects on both Windows and Linux platforms. It works well for me!

Formatted for copy and paste:

*.o *.lo *.la #*# .*.rej *.rej .*~ *~ .#* .DS_Store thumbs.db Thumbs.db *.bak *.class *.exe *.dll *.mine *.obj *.ncb *.lib *.log *.idb *.pdb *.ilk *.msi* .res *.pch *.suo *.exp *.*~ *.~* ~*.* cvs CVS .CVS .cvs release Release debug Debug ignore Ignore bin Bin obj Obj *.csproj.user *.user *.generated.cs

Formatted for readability:

*.o *.lo *.la #*# .*.rej *.rej
.*~ *~ .#* .DS_Store thumbs.db 
Thumbs.db *.bak *.class *.exe *.dll
*.mine *.obj *.ncb *.lib *.log 
*.idb *.pdb *.ilk *.msi* .res *.pch *.suo 
*.exp *.*~ *.~* ~*.* cvs  CVS .CVS .cvs  
release Release debug Debug
ignore Ignore bin Bin obj  Obj
*.csproj.user *.user
*.generated.cs
Leniel Maccaferri
  • 100,159
  • 46
  • 371
  • 480
Zach Burlingame
  • 13,476
  • 14
  • 56
  • 65
  • @blorgbeard - I'm rolling back your formatting changes because I believe it's preferrable to have it all on one line for copy/paste into the SVN configuration file (which doesn't accept multi-line input). – Zach Burlingame Jul 12 '09 at 16:25
  • 3
    Also, if you do WPF *.g.vb *.g.cs *.baml *.GenerateResource.Cache *.cache – Bob King Jul 17 '09 at 17:15
  • 6
    is *.dll required as it may be case when the reference assemblies needs to be commited also in repository? – Jaroslav Urban Apr 08 '10 at 09:43
  • 6
    @Xabatcha - You can always explicitly include a file of any extension (or folder) regardless of whether it is listed in the global ignore pattern or not. Generally you do not want *.dll being tracked by SVN however you can always explicitly add any necessary ones (which I often do in the case of third-party assemblies). – Zach Burlingame Apr 08 '10 at 20:03
  • 2
    If you're using ReSharper the add that too – autonomatt May 11 '10 at 16:16
  • Add *.xap for Silverlight projects. – Matt Casto Aug 05 '10 at 12:42
  • 1
    If you're using NuGet you should add _packages_ and allow nuget to download missing packages during build – jitidea May 23 '13 at 07:04
  • Hi, on windows 7, where to put this? – Krunal May 08 '14 at 11:16
  • New versions of VS create crazy .ipch files and folders. Your answer is in the top of the list. Please add this file/folder to the ignore list – cha Jan 27 '16 at 01:30
  • Incidentally the command to set this on the current dir (instead of in configuration) from svn 1.8 on is: svn propset svn:global-ignores "bin obj" . – markmnl May 12 '16 at 01:19
45

Based on Burly's ignore pattern, I have added ReSharper to the ignore list

Formatted for copy and paste:

*.o *.lo .la ## .*.rej .rej .~ ~ .# .DS_Store thumbs.db Thumbs.db *.bak *.class *.exe *.dll *.mine *.obj *.ncb *.lib *.log *.idb *.pdb *.ilk .msi .res *.pch *.suo *.exp ~. cvs CVS .CVS .cvs release Release debug Debug ignore Ignore bin Bin obj Obj *.csproj.user *.user _ReSharper.* *.resharper.user

Formatted for readability:

*.o *.lo .la ## .*.rej .rej .~ ~ .# .DS_Store thumbs.db Thumbs.db *.bak
*.class *.exe *.dll *.mine *.obj *.ncb *.lib *.log *.idb *.pdb *.ilk .msi .res *.pch *.suo *.exp ~. cvs
CVS .CVS .cvs release Release debug
Debug ignore Ignore bin Bin obj Obj
*.csproj.user *.user _ReSharper.* *.resharper.user
oleksii
  • 35,458
  • 16
  • 93
  • 163
36

My ignore pattern for Visual Studio:

*/bin */obj */Release */Debug *.suo *.err *.log *.obj *.bin *.dll *.exe *.LOG *.user *.pdb [tT]emp [tT]empPE Ankh.Load thumbs.db *.resharper *.vspscc *.vsssccc *.scc */_ReSharper* */_ReSharper.* bin obj *.resharperoptions *.db *.bak *_ReSharper* *.snk logs output TestResults *.crunchsolution.* *.crunchproject.*

Formatted for readability

*/bin */obj */Release */Debug *.suo *.err *.log *.obj *.bin *.dll *.exe 
*.LOG *.user *.pdb [tT]emp [tT]empPE Ankh.Load thumbs.db *.resharper 
*.vspscc *.vsssccc *.scc */_ReSharper* */_ReSharper.* bin obj 
*.resharperoptions *.db *.bak *_ReSharper* *.snk logs output TestResults 
*.crunchsolution.* *.crunchproject.*
user692942
  • 16,398
  • 7
  • 76
  • 175
Dima Pasko
  • 1,170
  • 12
  • 20
16

Every time I come across a file I generally do not want in the repository, I update the pattern. I believe there is no "best" pattern - it always depends on the language and environment you develop in.

Moreover, you're not very likely to think of all the possible "ignorable" filetypes - you'll always encounter a filetype you simply forgot to include. Thats why updating the pattern as you go works the best.

petr k.
  • 8,040
  • 7
  • 41
  • 52
  • 2
    I agree there is no "best" pattern in the absolute sense, which i why I added the (or as good as possible). You are correct, you won't enumerate all of them and it does depend on the lang & env, which I also stated. However, there are a large number you _can_ knock out right off the bat. – Zach Burlingame Sep 17 '08 at 17:10
  • 1
    Also while adding them as you go works alright for single developer environments, when you have multiple developers on a project, having a common project ignore pattern is desirable. You want to have to update it as infrequently as possible, so you want to knock out as many as possible up front – Zach Burlingame Sep 17 '08 at 17:10
  • Of course, the usual pattern of *.bin *.bak *.pdb *.suo etc etc must be set up front, I agree. But once you set the ignore properties on a repository folder, they do effectively become shared - although I am aware this is not exactly what you meant. – petr k. Sep 17 '08 at 17:21
11

Windows users might want to throw in desktop.ini and thumbs.db.

harpo
  • 41,820
  • 13
  • 96
  • 131
5

Used for my Visual Studio projects

*/bin */obj *.user *.suo

You can expand more file types from there.

Daniel A. White
  • 187,200
  • 47
  • 362
  • 445
icelava
  • 9,787
  • 7
  • 52
  • 74
  • I saw a similar list earlier today -- what's the difference between */bin and just bin? Assuming you want to ignore the whole folder. – harpo Sep 17 '08 at 17:03
  • Read section 5.13. Ignoring Files And Directories of the TortoiseSVN help file. – icelava Sep 18 '08 at 14:31
  • 5
    http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-dug-ignore.html There it says that you shouldn't include a / or \, and that including them is a legacy of earlier versions – Simon D Jul 09 '09 at 15:33
  • @Simon, isn't it saying (in the "No Paths in Global Ignore List" inset) that paths are okay in `svn:ignore`, but not in the global ignore list? – Matthew Flaschen Oct 12 '11 at 17:19
3

Visual Studio (VC++) users definitely need to exclude the .ncb files

Rob Walker
  • 46,588
  • 15
  • 99
  • 136
1

Since you may be using third party libs and dll's as part of the project(s) then I don't see the wisdom in blocking *.lib and *.dll from the repository. These are the things that are meant to be stored in the repository.

graham.reeds
  • 16,230
  • 17
  • 74
  • 137
  • 5
    When using third party libs, dlls, exes, etc. just explicitly add them. If you want to a do an entire 3rd party tree, just temporarily disable the ignore pattern. You don't want these types being picked up implicitly during day-to-day development however, hence their inclusion in the pattern. – Zach Burlingame Oct 09 '08 at 15:18
1

Visual Studio 2010 users should add ipch (a folder which contains C++ precompiled headers) and *.sdf (huge files used by intellisense for any kind of project).

Dalmas
  • 26,409
  • 9
  • 67
  • 80
1

Mac users probably want to throw in .DS_Store. In addition, if there are dev's using Emacs or Vim, you probably want to add ~~ and ##.

Jim Deville
  • 10,632
  • 1
  • 37
  • 47
1

For Eclipse, I use:

bin
.*

.* gets all the project configuration. You almost never want to check in a 'hidden' directory or file, but if it comes up, you can still svn add it.

noah
  • 21,289
  • 17
  • 64
  • 88
0

And core dumps (cygwin, linux)

*.stackdump core.*
Holger Bille
  • 2,421
  • 1
  • 16
  • 20
0

Gotta add Resharper to the mix if you use one.

another one to look out for is Ankh*.*

  • Yeah, I left out most of the tool specific flags except for Visual Studio. Hopefully others continue to add answers with explicit file pattern lists for their various tools! – Zach Burlingame Jun 22 '10 at 12:36
0

gitignore.io provides configurable patterns for git. They provide a readable list, which you need to reformat for SVN.

For instance, requesting MicrosoftOffice and Windows returns

# Created by https://www.gitignore.io/api/microsoftoffice,windows

### MicrosoftOffice ###
*.tmp

# Word temporary
~$*.doc*

# Excel temporary
~$*.xls*

# Excel Backup File
*.xlk

# PowerPoint temporary
~$*.ppt*

# Visio autosave temporary files
*.~vsdx


### Windows ###
# Windows image file caches
Thumbs.db
ehthumbs.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msm
*.msp

# Windows shortcuts
*.lnk
koppor
  • 19,079
  • 15
  • 119
  • 161
0

gitignore.io provides configurable patterns for git. They provide a readable list, which you need to reformat for SVN.

For instance, requesting MicrosoftOffice and Windows returns

# Created by https://www.gitignore.io/api/microsoftoffice,windows

### MicrosoftOffice ###
*.tmp

# Word temporary
~$*.doc*

# Excel temporary
~$*.xls*

# Excel Backup File
*.xlk

# PowerPoint temporary
~$*.ppt*

# Visio autosave temporary files
*.~vsdx


### Windows ###
# Windows image file caches
Thumbs.db
ehthumbs.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msm
*.msp

# Windows shortcuts
*.lnk

It seems that it can be directly used as svn:global-ignore

koppor
  • 19,079
  • 15
  • 119
  • 161
0

Don't forget NCrunch temporary files:

*.crunchsolution.* *.crunchproject.*
Richard Dingwall
  • 2,692
  • 1
  • 31
  • 32
0

The pattern depends on which operating system you're using.

On Linux, you'll want to block **.o*, **.so*, **.a*, and **.la* to begin with. You may also want to block **~* (backup file from editing) and #*# (emacs backup from a crash).

On Windows, you'll want **.obj*, **.lib*, and **.dll* at the very least.

Any other files you need to block depend on your IDE, editor, and compiler.

Branan
  • 1,819
  • 15
  • 21