Gitignore Not Showing in VS Code Explorer? Fix It
In this article
If your .gitignore file is not appearing in the VS Code file explorer, the cause is almost always one of three things: the file was never actually created, VS Code is hiding it through its own files.exclude setting, or the file is being filtered out by the explorer's exclude pattern for dotfiles. The fastest fix is to open the integrated terminal, run ls -a (macOS/Linux) or dir /a (Windows) to confirm the file exists, then check Settings > files.exclude and remove any pattern that matches .gitignore. If the file is genuinely missing, create it with touch .gitignore or echo.>.gitignore and it will appear in the explorer immediately.
This guide walks through confirming whether the file exists, checking the two VS Code settings that hide it, and troubleshooting the cases where the file is present but the explorer still refuses to show it. Menu labels can differ slightly by VS Code version, operating system, or region, so if a label does not match exactly, look for the closest equivalent.
What You'll Need
- VS Code installed and the project folder opened (not just a single file).
- Access to the integrated terminal in VS Code (View > Terminal, or Ctrl+` on Windows/Linux, Cmd+` on macOS).
- Basic familiarity with the file explorer sidebar on the left.
- Optional: Git installed if you want to verify ignore rules are working.
Step-by-Step
- Confirm the file actually exists on disk. Open the integrated terminal (View > Terminal) and run
ls -aon macOS/Linux ordir /aon Windows. The-aand/aflags show hidden files, including dotfiles. If.gitignoreis not listed, it was never created — skip to step 3. If it is listed, continue to step 2. - Check VS Code's own exclude setting. Open Settings with Ctrl+, (Cmd+, on macOS) and search for
files.exclude. This setting controls which files the explorer hides. If you see a pattern like**/.gitignoreor a wildcard such as**/.*, that is why the file is invisible. Remove the offending pattern or set it tofalse, then close and reopen the explorer. The file should reappear. - Create the file if it is missing. In the terminal, run
touch .gitignoreon macOS/Linux orecho.>.gitignorein Windows Command Prompt (orNew-Item .gitignorein PowerShell). Alternatively, right-click in the explorer, choose New File, and type.gitignoreexactly. VS Code will create it and show it in the tree. - Check the explorer's exclude filter. At the top of the Explorer panel there is a filter icon (sometimes labeled "Filter" or shown as a funnel). If a filter string is active, it can hide dotfiles. Clear the filter box and the file should return.
- Verify the workspace root. Make sure you opened the folder that contains
.gitignore, not a parent or child folder. Use File > Open Folder and select the correct directory. The explorer only shows files under the opened root. - Reload the window. Press Ctrl+Shift+P (Cmd+Shift+P on macOS), type
Developer: Reload Window, and press Enter. This refreshes the explorer without closing VS Code and often resolves stale display issues. - Confirm Git is tracking the file (optional). In the terminal, run
git status. If.gitignoreappears as untracked or modified, Git sees it. If Git does not see it, the file may be outside the repository root — move it to the top level of the repo.
Common Mistakes
- Creating the file with a different name. Typing
gitignorewithout the leading dot creates a normal file that Git ignores. The dot is required. - Editing
files.excludebut notsearch.exclude. These are separate settings. Hiding a file from search does not hide it from the explorer, and vice versa. Check both if the file is missing in one place but not the other. - Confusing
.gitignorewith.git/info/exclude. The latter is a local ignore file inside the.gitdirectory and is not meant to appear in the explorer. Only.gitignoreat the project root is the file you normally edit. - Assuming the file is hidden when it is just scrolled out of view. Long file trees can push dotfiles below the fold. Collapse folders or use the explorer's filter to search for
.gitignoreby name. - Using a global ignore pattern that matches everything. A pattern like
.*infiles.excludehides all dotfiles, including.gitignore,.env, and.eslintrc. Remove it if you need to see them.
Tips
- Keep
files.excludeminimal. Hiding build output likenode_modulesis fine, but hiding all dotfiles makes configuration files hard to find. - Use the Quick Open palette (Ctrl+P or Cmd+P) and type
.gitignoreto jump straight to the file even if the explorer hides it. - If you work across multiple projects, set exclude patterns per workspace rather than globally so one project's settings do not hide files in another.
- Remember that
.gitignoreonly affects untracked files. Files already tracked by Git remain tracked even if you add them to.gitignorelater; you must untrack them explicitly withgit rm --cached.
Troubleshooting
The file exists in the terminal but not in the explorer. Recheck files.exclude and the explorer filter. Also confirm you are looking at the correct folder in the sidebar — VS Code may have multiple root folders open in a workspace.
I removed the exclude pattern but the file still does not show. Reload the window with Developer: Reload Window. If that fails, close VS Code completely and reopen the folder.
The file shows in the explorer but Git ignores it. That is expected if the file is empty or if it is itself listed in another ignore file. Check git check-ignore -v .gitignore to see which rule is matching.
I cannot create a file starting with a dot. Some file managers block dotfiles by default. Create it from the VS Code terminal instead, or use the New File command in the explorer and type the full name including the dot.
The explorer shows a file called .gitignore but it is greyed out. Greyed-out files are ignored by Git, not hidden by VS Code. This is normal for files matched by ignore rules. If you need to edit it, double-click it — it is still editable.
Frequently Asked Questions
Why is my .gitignore file not visible in VS Code?
Most often because VS Code's files.exclude setting contains a pattern that matches dotfiles, or because the file was never created. Check the terminal first, then the setting.
Does VS Code hide dotfiles by default?
No. VS Code shows dotfiles by default. If yours are hidden, a setting or filter was changed, either globally or in the workspace.
How do I show hidden files in the VS Code explorer?
Open Settings, search for files.exclude, and remove any pattern that hides the files you want to see. Also clear the explorer filter box at the top of the sidebar.
Can I edit .gitignore if I cannot see it?
Yes. Use Quick Open (Ctrl+P or Cmd+P) and type the filename, or open it from the integrated terminal with a command-line editor. The file does not need to be visible in the explorer to be edited.
Why does .gitignore not appear in Git status?
Git does not list ignored files in git status by default. If .gitignore itself is untracked, it should appear. If it does not, it may be listed in another ignore file or outside the repository root.
Does the .gitignore file need to be at the project root?
It works at any level, but rules apply relative to the folder containing the file. Placing it at the repository root is the common convention and makes the rules apply project-wide.