Vagrant .gitignore template
The Vagrant template is two rules long, covering the working directory that holds machine identifiers and a generated SSH private key, and the packaged box archives.
At a glance
- Category
- Infrastructure
- Patterns in this template
- 2 rules
- Directories ignored
- 1 of the 2 rules end in a slash, so they match directories only
- Also needs an OS template
- Yes. This template covers two paths and nothing else.
- Typical companions
- The language template for the project running inside the machine, plus an OS template.
In detail
.vagrant is the working directory created beside the Vagrantfile the first time you bring a machine up. It records the identifier the provider assigned to each machine, which provider is in use, and the state the tool believes each machine is in. Those identifiers refer to virtual machines that exist only on one person's computer, so a committed copy points at machines nobody else has.
It also holds a generated private key. On first boot the tool replaces the well known default key pair with a freshly generated one and stores the private half inside that directory. Committing it publishes a working SSH key, and although it only opens a local development machine, it is a private key in a repository, which is worth avoiding on principle and on any security scan.
*.box covers packaged base images. A box is a compressed disk image of an entire operating system, typically hundreds of megabytes and often several gigabytes. They are downloaded from a registry or built by a packaging tool, and they are the single fastest way to make a repository unusable if one gets committed by accident.
The Vagrantfile itself is deliberately not ignored. It is the definition of the environment: which box, how much memory, which ports are forwarded, which provisioning scripts run. It is source in the same sense a Dockerfile is, and it is the file that makes the whole arrangement reproducible.
What the template does not cover is a provisioning script holding credentials. Shell provisioners are ordinary files in the repository, and a line exporting a real API key into the machine is a normal way for a secret to end up tracked without anyone thinking about it.
Examples
.vagrant/
*.box2 lines exactly as the tool writes them, before any common additions you tick.
Things that catch people out
- The generated private key inside .vagrant is a real key. If it was ever committed, delete the machine and let the tool generate a new pair rather than assuming a local machine does not count.
- A committed .box file stays in the history forever and dominates every clone. Rewriting history is the only way to remove it, which is why the rule matters before the first commit rather than after.
- Provisioning scripts are tracked by design. Nothing here stops a shell provisioner exporting a real credential, so review those files separately.
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 →Docker .gitignore template
A small template with two rules worth questioning: it ignores .dockerignore, and it ignores every compose file except two, which suits few projects.
Terraform .gitignore template
State files contain secrets in plain text and must never be committed. This template covers that, and also ignores the lock file, which should be tracked.
Linux .gitignore template
The shortest template in the collection. Five rules covering editor backup files, file manager settings, per volume trash and NFS silly rename files.
JavaScript .gitignore template
Every rule in the JavaScript .gitignore template explained: why node_modules is restored rather than committed, and what the old package folders catch.
TypeScript .gitignore template
The TypeScript template ignores compiled output, source maps and build info, but its *.d.ts rule is broader than most projects want. Here is each line.
Python .gitignore template
A line by line read of the Python .gitignore template: bytecode caches, virtual environments, packaging output, test caches and the lib/ rule that bites.
Tools for this
- .gitignore Generator Generate .gitignore files for any project - 50+ templates for languages, frameworks, IDEs, and OS