TortoiseGit Shell Extension and Git for Windows: which ignore file does "Add to ignore list" actually update?
0 reputation · 02 Jun 2021, 20:34 UTC
0 reputation · 02 Jun 2021, 20:34 UTC
I want a predictable way to manage ignore rules from TortoiseGit's context menu so that files ignored via the GUI behave identically to files ignored by editing .gitignore from the Git CLI. The two components involved are the TortoiseGit Windows Shell Extension and the Git for Windows binary it wraps (TortoiseGit 2.x with a current Git for Windows installation).
TortoiseGit offers ignore actions from the Explorer context menu, and Git itself supports at least two distinct mechanisms: the versioned .gitignore file and the repository-local .git/info/exclude file, which is not shared with other clones. It is not clear to me which of these the GUI's ignore action writes to, whether the behavior is configurable, and whether it differs between ignoring a single file and ignoring by wildcard or extension. I also want to avoid a situation where a teammate cloning the repository does not inherit the ignore rules I created through the GUI.
.gitignore, .git/info/exclude, or does it offer both, and is this documented behavior?35275 reputation · 03 Jun 2021, 00:03 UTC
In TortoiseGit 2.x, the context menu distinguishes between a direct "Add to .gitignore" command and "Add to ignore list", which opens a selection dialog. The dialog is the intended entry point for choosing a target; it does not write to a single hard-coded file. You pick the destination each time. The dialog typically offers a versioned .gitignore (usually the nearest one up to the repository root), the repository-local .git/info/exclude, and your user-level global ignore file.
Likely: The dialog defaults to a .gitignore file, so rules created this way are shared on clone. This is the expected behavior for current 2.x releases, though older forum posts sometimes conflate the action with .git/info/exclude.
Confirmed: The dialog allows per-invocation override, so the file written depends on your selection. A global TortoiseGit preference controls the default target; it is not per-repository. The target does not differ between single-file, wildcard, or extension patterns.
.gitignore and .git/info/exclude to see where the pattern landed.*.log to confirm the target stays the same.To share a rule with teammates, ensure the dialog targets a .gitignore file. For a local-only rule, choose .git/info/exclude. Because the default preference is global, changing it affects every repository on that machine.
Conservative note: Dialog wording and defaults have varied across 2.x releases. If your menu writes immediately without a dialog, or lacks a .gitignore option, the exact TortoiseGit version matters for a definitive answer.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.