19 May 2010

.gitignore Config File For .NET Projects

7 Comments Uncategorized

I wanted to post this mostly for my future reference.  But I think it is also equally as useful to anybody else with a .NET project that is using the Git as their source control, and want to make sure non-code extras that come with .NET projects don’t get checked in.

.gitignore File

This file specifies the paths and files to ignore in your project.  Each line constitutes a new path, and each one can use basic RegEx to generalize the ignore checking.

To create the file run the following commands from your Git command prompt for windows use msysgit, or Linux and Mac OSX you can use the native command line for this.

touch .gitignore
{{ Add The Text In The Next Part }}
git add .gitignore
git commit -am "adding ignore checking paths for this project"
git push origin master

Or you can just create a file named “.gitignore” in notepad and save it and use your favorite Git client.

[Oo]bj/
[Bb]in/
*.suo
*.user
/TestResults
*.vspscc
*.vssscc

If you have any ignore statements that you find useful for your projects, I am interested in growing this file, so leave them down in the comments.

Tags: ,
written by
Nick Berardi
subscribe
If you found this post valuable and would like to see more like it you can follow me.

7 Responses to “.gitignore Config File For .NET Projects”

  1. Reply JP Toto says:

    Our typical setup:

    obj
    bin
    _ReSharper.*
    *.csproj.user
    *.resharper.user
    *.resharper
    *.suo
    *.cache
    *~
    *.swp
    *.resharper.user
    *.rptproj.user
    *.db

  2. Reply Rune Jacobsen says:

    I just started out with msysgit, and found out that when doing Silverlight development, adding *.xap to the list was a good idea. :)

  3. Reply thinkbeforecoding says:

    This is the content of my .hgignore file (ok this is for mercurial, but i’m sue everyone can understand !)

    #ignore files
    glob:_ReSharper.*/
    glob:TestResults/
    glob:**/[bB]in/
    glob:**/[oO]bj/
    glob:*.suo
    glob:**.vssscc
    glob:**.vspscc
    glob:**.ReSharper
    glob:**.user
    glob:**/[Ww]eb.config
    glob:**/[Aa]pp.config
    glob:UpgradeLog*.XML
    glob:**/UpgradeReport*.*
    glob:**.Publish.xml

    It ignores Resharper files and directories, MSTest directories, and upgrade logs and reports.
    it also ignores web.config and app.config so that devs can have their own (of course a web.template.config is available and included in the project). This could change with new web.config transformation capabilities in VS2010

  4. Reply Rodney says:

    Good post. The file is called “gitignore”. You have “getignore” above.

  5. Reply Chui Tey says:

    also ClientBin/

Leave a Reply