TortoiseGit Manual

Ignoring Files And Directories

Figure 2.30. Explorer context menu for unversioned files

Explorer context menu for unversioned files

In most projects you will have files and folders that should not be subject to version control. These might include files created by the compiler, *.obj, *.lst, maybe an output folder used to store the executable, bin/, obj/. More examples include user-specific workspace settings *.suo, *.user(Visual Studio), backup files *.bak, Backup*/, Shell metadata files Thumbs.db, Desktop.ini, .DS_Store/. Whenever you commit changes, TortoiseGit shows your unversioned files, which fills up the file list in the commit dialog. Of course you can turn off this display, but then you might forget to add a new source file.

The best way to avoid these problems is to add the derived files to the project's ignore list. That way they will never show up in the commit dialog, but genuine unversioned source files will still be flagged up.

If you right click on one or more unversioned files, and select the command TortoiseGitAdd to Ignore List from the context menu, a submenu appears allowing you to select ignore by names or by extensions. Ignore dialog shows that allows you to select ignore type and ignore file.

Figure 2.31. Ignore dialog

Ignore dialog

Ignore Type

Ignore item(s) only in containing folder(s)

Only ignore the selected pattern(s) within that folder(s).

Ignore item(s) recursively

Ignore items with the selected pattern(s) in that folder(s) and child folder(s).

Ignore File

.gitignore in the repository root

Write the ignore entries in .gitignore in the repository root. This allows you to synchronize the ignore list with remote repository.

.gitignore in the containing directories of the items

Write the ignore entries in .gitignore in the containing directories of the items. This allows you to synchronize the ignore list with remote repository.


Write the ignore entries in .git/info/exclude in repository metadata. This allows you to store the ignore list locally, but cannot synchronize with remote repository.

If you want to remove one or more items from the ignore list, in current version of TortoiseGit, you have to manually edit the ignore list file using a text editor that can handle Unix EOL. That allows you to specify more general patterns using filename globbing, described in the section below. Read the section called “gitignore(5)” for more information. Please be aware that each ignore pattern has to be placed on a separate line. Separating them by spaces does not work.

Pattern Matching in Ignore Lists

Git's ignore patterns make use of filename globbing, a technique originally used in Unix to specify files using meta-characters as wildcards. The following characters have special meaning:


Matches any string of characters, including the empty string (no characters).


Matches any single character.


Matches any one of the characters enclosed in the square brackets. Within the brackets, a pair of characters separated by - matches any character lexically between the two. For example [AGm-p] matches any one of A, G, m, n, o or p.

Pattern matching is case sensitive, which can cause problems on Windows. You can force case insensitivity the hard way by pairing characters, eg. to ignore *.tmp regardless of case, you could use a pattern like *.[Tt][Mm][Pp].