Rust .gitignore Template

The full, current Rust .gitignore template — copy it as-is, or head to the .gitignore Generator to merge it with other stacks into one file.

Template

# Generated by Cargo
# will have compiled files and executables
debug
target

# These are backup files generated by rustfmt
**/*.rs.bk

# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb

# Generated by cargo mutants
# Contains mutation testing data
**/mutants.out*/

# rustc will dump stack traces when hitting an internal compiler error to PWD
rustc-ice-*.txt

# RustRover
#  JetBrains specific template is maintained in a separate JetBrains.gitignore that can
#  be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
#  and can be added to the global gitignore or merged into this file.  For a more nuclear
#  option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

What each entry does

Why every line in this template is excluded, not just what it matches.

Entry Why it's excluded
debug A generated/local directory (debug) — excluded because its contents are either build output or machine-specific state, not source you'd want to review in a diff.
target Rust/Cargo's (and Maven's) build output directory — large, fully derived from source, and machine-specific.
**/*.rs.bk Files matching **/*.rs.bk — a generated or machine-specific file type for this stack, safe to regenerate rather than track.
*.pdb A debug symbol file generated alongside a compiled binary — build output, and can be large.
**/mutants.out*/ A generated/local directory (**/mutants.out*) — excluded because its contents are either build output or machine-specific state, not source you'd want to review in a diff.
rustc-ice-*.txt Files matching rustc-ice-*.txt — a generated or machine-specific file type for this stack, safe to regenerate rather than track.