Rails .gitignore template
The Rails template ignores the master key and credential keys while leaving the encrypted credentials file tracked, alongside logs, temporary files and uploaded storage.
At a glance
- Category
- Framework
- Patterns in this template
- 26 rules
- Directories ignored
- 4 of the 26 rules end in a slash, so they match directories only
- Also needs an OS template
- Yes. Nothing here matches file manager or editor artefacts.
- Typical companions
- Ruby for the bundler and gem rules, plus an OS template.
In detail
The credentials rules are the ones to understand, because they encode a deliberate split. config/master.key and config/credentials/*.key are the decryption keys and are ignored. config/credentials.yml.enc appears in the template too, and this is where projects differ: the framework's own design intends the encrypted file to be committed, since it is useless without the key. Ignoring both halves means new developers have no way to get the credentials at all.
config/initializers/secret_token.rb is the older mechanism the credentials system replaced. It held the session signing secret in plain Ruby, and a leaked one lets an attacker forge session cookies. Keeping the rule costs nothing and protects an older application that has not migrated.
The anchored rules cover runtime directories: /log, /tmp and /storage. Logs are append only and machine specific. The tmp directory holds caches, process ids and sockets. /storage is where the file attachment system puts uploaded files in development, so it holds user content rather than project content.
The database rules cover /db/*.sqlite3 and its journal and numbered variants, which is the development database. /public/system, /public/packs and /public/packs-test are asset output directories from the older attachment and bundling systems, produced by a build step from tracked sources. All three are anchored to the root, so an engine mounted inside the application keeps its own equivalents and needs its own rules.
The test rules cover capybara-*.html and pickle-email-*.html, which are page and email snapshots written when an integration test fails, plus /spec/tmp, rerun.txt and /coverage. .byebug_history is the debugger's command history, which records every expression evaluated at a breakpoint including anything you printed to check a value.
Examples
*.rbc
capybara-*.html
.rspec
/db/*.sqlite3
/db/*.sqlite3-journal
/db/*.sqlite3-[0-9]*
/public/system
/coverage/
/spec/tmp
*.orig
rerun.txt
pickle-email-*.html
config/initializers/secret_token.rb
config/master.key
config/credentials/*.key
/tmp/
/log/
/storage/
.byebug_history
config/credentials.yml.enc
/public/packs
/public/packs-test
/node_modules
/yarn-error.log
yarn-debug.log*
.yarn-integrity26 lines exactly as the tool writes them, before any common additions you tick.
Things that catch people out
- config/credentials.yml.enc is ignored by this template, which conflicts with how the credentials system is meant to work. The encrypted file is safe to commit and useless without the key, so most teams remove that line and keep only the key rules.
- If config/master.key was ever committed, every encrypted credential in the repository is readable by anyone with a clone. Rotate the key and re-encrypt rather than just removing the file.
- /storage is anchored to the root, so an engine or subproject with its own storage directory is not covered.
Try it: .gitignore Generator
Pick one or more templates, tick the common additions you want, and copy or download the combined .gitignore.
.gitignore Generator
LOCAL · Browser-OnlyGenerate comprehensive .gitignore files by combining templates for languages, frameworks, IDEs, and operating systems
Language
Framework
IDE
OS
Build Tool
Infrastructure
Common Additions
Preview
Select templates or common additions to generate a .gitignore file.
Related .gitignore templates
All .gitignore templates →Ruby .gitignore template
The Ruby template anchors most rules to the repository root with a leading slash, and ignores Gemfile.lock, which is right for a gem and wrong for an app.
Django .gitignore template
The Django template adds four framework rules to the usual Python ones: local settings, the SQLite database, uploaded media and collected static files.
PHP .gitignore template
The PHP template ignores the vendor directory and the .env file, and also ignores composer.lock, which most application projects should commit instead.
Spring Boot .gitignore template
The Spring Boot template covers both build tools at once and adds sections for three IDEs, which makes it broad but leaves application secrets uncovered.
.NET .gitignore template
The .NET template covers bin, obj and NuGet output, and ignores launchSettings.json, which holds the launch profiles and environment variables for local runs.
Flutter .gitignore template
The Flutter template adds generated plugin manifests and per platform build artefacts to the Dart rules, including the iOS pod directory and build modes.
Tools for this
- .gitignore Generator Generate .gitignore files for any project - 50+ templates for languages, frameworks, IDEs, and OS