github/gitignore · Rust.gitignore

Rust .gitignore 템플릿 해설

Rust.gitignore가 target 디렉터리, rustfmt 백업, MSVC 디버그 정보, cargo-mutants 결과를 무시하는 이유와 Cargo.lock 커밋 권장 변경을 설명합니다.

생성기에서 열기 VisualStudioCode, JetBrains, macOS 함께 열기

Rust.gitignore는 Cargo 프로젝트에 필요한 최소한의 규칙만 담은 짧은 템플릿이다. 대부분의 산출물이 target/ 하나에 모이기 때문에 규칙 수가 적다.

예전 템플릿은 라이브러리일 때 Cargo.lock을 무시하라고 안내했지만, 지금 템플릿에는 그 규칙이 없다. Rust 팀은 2023년에 권장 사항을 바꿔 라이브러리를 포함한 모든 프로젝트에서 Cargo.lock 커밋을 기본으로 삼았다.

규칙별 해설

패턴무엇을, 왜 무시하나
targetdebugCargo 빌드 결과cargo build가 컴파일 결과, 증분 빌드 캐시, 의존성 빌드물을 넣는 폴더다. 수 GB까지 커질 수 있고 완전히 재생성된다. 끝에 /가 없어 같은 이름의 파일도 무시된다.
**/*.rs.bkrustfmt 백업rustfmt가 파일을 고치기 전에 남기는 백업이다. **/로 시작해 모든 깊이에서 일치한다.
*.pdbMSVC 디버그 정보Windows MSVC 툴체인으로 빌드할 때 생기는 디버그 심볼 데이터베이스다.
**/mutants.out*/변이 테스트 결과cargo-mutants가 만드는 결과 디렉터리(mutants.out, mutants.out.old)다. 끝의 / 때문에 디렉터리에만 일치한다.
rustc-ice-*.txt컴파일러 내부 오류 덤프rustc가 내부 컴파일러 오류(ICE)를 만났을 때 현재 디렉터리에 남기는 스택 트레이스다. 버그 신고에는 쓰지만 저장소에는 필요 없다.

실무에서 주의할 점

원본 템플릿

Rust.gitignore규칙 6줄
# Generated by Cargo# will have compiled files and executablesdebugtarget# 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 PWDrustc-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/

템플릿 출처: github/gitignore/Rust.gitignore @356fd7b (2026-09-11) · CC0-1.0

함께 쓰는 템플릿

다른 템플릿 해설