Creating a .gitignore File inside Windows Explorer

comments

One of the first things i was frustrated by when i first started using the distributed source control Git on windows was creating a .gitignore file as i couldn’t only ever seem to figure it out using the command line – but today i found an interesting hack.

imageWhat is a .gitignore file?

When using the ever-growing-in-popularity Source Control provider Git (http://git-scm.com/) or the Windows implementation MsyGit (http://code.google.com/p/msysgit/) you often have files that you do not want to check into your source control.

This is similar to using the SVN:ignore command when using SVN.

To accomplish this you create a file in the root of your local repository called .gitignore that you enter all the filenames you would like to avoid having in your repository (when working with Visual Studio projects this is often your .suo and if you are a R# fan, your _Resharper folders).

Example .gitignore file

#OS junk files
[Tt]humbs.db
*.DS_Store

#Visual Studio files
*.[Oo]bj
*.user
*.aps
*.pch
*.vspscc
*.vssscc
*_i.c
*_p.c
*.ncb
*.suo
*.tlb
*.tlh
*.bak
*.[Cc]ache
*.ilk
*.log
*.lib
*.sbr
*.sdf
ipch/
obj/
[Bb]in
[Dd]ebug*/
[Rr]elease*/
Ankh.NoLoad

#Tooling
_ReSharper*/
*.resharper
[Tt]est[Rr]esult*

#Project files
[Bb]uild/

#Subversion files
.svn

# Office Temp Files
~$*

 

The Problem

When creating a .gitignore file in Windows Explorer you are met with a pretty annoying error message

“… You must type a file name …”

image

The Solution

Create your new text file by right-clicking in a folder and select New > Text File

image

When entering a new file-name, enter .gitignore. (with an extra period on the end)

Windows removes the end period, and leaves you with just .gitignore

Pretty cool eh?