.gitignore for Rust

5 ignore rules for Rust, ready to copy into your repository.

The Rust programming language

The complete .gitignore for Rust

# Generated by LFGitignore - https://lfgitignore.com
# Created: 2025-12-08 21:28:44 UTC
# Technologies: Rust

### Rust ###
debug
target
**/*.rs.bk
# Program debug database
*.pdb
**/mutants.out*/

What these Rust rules actually ignore

Every pattern below, and why it belongs in your .gitignore.

General

Pattern What it ignores
debug Generated by Cargo will have compiled files and executables
target General

These are backup files generated by rustfmt

Pattern What it ignores
**/*.rs.bk These are backup files generated by rustfmt

MSVC Windows builds of rustc generate these, which store debugging information

Pattern What it ignores
*.pdb Program debug database

Contains mutation testing data

Pattern What it ignores
**/mutants.out*/ Contains mutation testing data

How to use this .gitignore for Rust

  1. Copy the Rust rules above, or download the file directly.
  2. Create a file named .gitignore at the root of your Git repository and paste the rules into it.
  3. If some of those files are already tracked, run git rm -r --cached . then commit again — Git only applies ignore rules to untracked files.
  4. Commit the .gitignore so everyone on the team shares the same rules.

Other Language .gitignore templates

See every Language template