Keep a generated exception in a Next.js repository
Admin ·
Generate an initial .gitignore for the stacks your repository uses, then review source paths that broad presets might hide. A folder marker is a useful check because it needs an exception without excluding its parent directory.
Review the generated rule order
Load the example and choose Generate .gitignore. The preview shows 16 patterns and 4 repeats omitted. The initial Node.js and Next.js presets overlap on node_modules/, coverage/, *.tsbuildinfo and .env.local. Each of those rules appears once.
Find /generated/* under Custom ignore patterns. The later !/generated/.keep rule keeps the marker while excluding other generated files. Turn off Include section comments and regenerate. The same 16 patterns retain their order in the shorter file.
Check the marker and an editor setting with the same file
Choose Download .gitignore ZIP and extract .gitignore, then open it in Git Ignore Pattern Tester. Test generated/data.csv, generated/.keep, .vscode/settings.json and .vscode/extensions.json. The first and third paths are ignored. The second and fourth are included by exceptions.
Change /generated/* to /generated/ and compare again. The marker is now blocked by generated/. Restore /generated/* to keep the marker visible while ignoring other contents.
Git documentation, gitignore pattern and precedence rulesGit documentation, reporting matched patterns
Review presets against your source directories
Search the preview for general names such as dist/ and build/. Check any directories that contain hand-written source before saving the file at the repository root. Mark a repository-root path with a leading slash if the same name must remain eligible elsewhere.
Keep exceptions after the rules they override. The generator omits exact duplicate lines within runs that have the same rule polarity. It retains a later repeat across an exception boundary when dropping it could change behavior.
Common questions
What happens when a custom rule has an unclosed bracket?
The preview points to the input field and line. Fix the rule and generate again to enable copying and downloading.
How do I save the exact .gitignore filename?
Extract .gitignore from the ZIP and place it at the repository root. For the plain-text download, rename gitignore.txt to .gitignore, including the leading period.