github/gitignore · Rails.gitignore

Ruby on Rails .gitignore 템플릿 해설

Rails.gitignore가 log·tmp·storage, 개발용 SQLite, master.key, 프리컴파일 에셋, node_modules를 무시하는 이유와 .keep 부정 패턴 구조를 설명합니다.

생성기에서 열기 Ruby, Node, macOS 함께 열기

Rails.gitignore는 Rails 애플리케이션의 실행 중 생기는 파일과 비밀 정보를 막는다. 로그·임시 파일·업로드 파일처럼 서버가 동작하며 쌓는 데이터와, 에셋 파이프라인이 만드는 결과물이 주 대상이다.

/log/*!/log/.keep처럼 폴더 안의 내용만 제외하고 빈 표시 파일은 남기는 패턴이 세 번 나온다. git은 빈 디렉터리를 저장하지 않으므로, 폴더 구조를 유지하려면 이런 방식이 필요하다.

규칙별 해설

패턴무엇을, 왜 무시하나
/log/*/tmp/*/storage/*!/log/.keep!/tmp/.keep!/storage/.keep로그·임시·저장소 폴더실행 로그, 캐시·pid 파일, Active Storage 로컬 업로드가 쌓이는 폴더다. 내용은 제외하되 .keep 파일을 되살려 폴더가 저장소에 남게 한다. /log/처럼 디렉터리 자체를 제외하면 .keep을 되살릴 수 없다.
config/master.keyconfig/initializers/secret_token.rb.env.env*.local비밀 키config/master.key는 암호화된 credentials.yml.enc를 여는 열쇠다. 이 파일이 새면 모든 자격 증명이 노출되므로 절대 커밋하지 않는다. 암호화된 credentials 파일 자체는 커밋해도 된다.
/db/*.sqlite3/db/*.sqlite3-journal/db/*.sqlite3-[0-9]*개발용 데이터베이스개발·테스트용 SQLite 파일이다. db/schema.rb와 마이그레이션은 커밋하고, 데이터 파일은 각자 만든다.
/public/assets/public/packs/public/packs-test/public/system/public/uploads프리컴파일 에셋·팩assets:precompile과 Webpacker가 만든 결과, 그리고 업로드 파일이다. 배포 과정에서 다시 만든다.
/.bundle/vendor/bundlenode_modules//vendor/assets/bower_components/yarn-error.log.yarn-integrityBundler·Node 의존성설치하면 다시 생기는 gem과 JavaScript 패키지, 설치 로그다.
/coverage//spec/tmpcapybara-*.htmlrerun.txtpickle-email-*.html.rspec테스트 부산물커버리지 결과, Capybara가 실패 시 저장하는 페이지, Cucumber 재실행 목록이다. .rspec은 개인 RSpec 옵션 파일로 취급한다.
.byebug_history.rvmrc.powenv*.rbc*.orig개인 도구 설정디버거 기록, 옛 RVM·Pow 설정, 병합 도구가 남긴 원본 백업이다.

실무에서 주의할 점

원본 템플릿

Rails.gitignore규칙 38줄
*.rbccapybara-*.html.rspec/db/*.sqlite3/db/*.sqlite3-journal/db/*.sqlite3-[0-9]*/public/system/coverage//spec/tmp*.origrerun.txtpickle-email-*.html# Ignore all logfiles and tempfiles./log/*/tmp/*!/log/.keep!/tmp/.keep# TODO Comment out this rule if you are OK with secrets being uploaded to the repoconfig/initializers/secret_token.rbconfig/master.key# Only include if you have production secrets in this file, which is no longer a Rails default# config/secrets.yml# dotenv, dotenv-rails# TODO Comment out these rules if environment variables can be committed.env.env*.local## Environment normalization:/.bundle/vendor/bundle# these should all be checked in to normalize the environment:# Gemfile.lock, .ruby-version, .ruby-gemset# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:.rvmrc# if using bower-rails ignore default bower_components path bower.json files/vendor/assets/bower_components*.bowerrcbower.json# Ignore pow environment settings.powenv# Ignore Byebug command history file..byebug_history# Ignore node_modulesnode_modules/# Ignore precompiled javascript packs/public/packs/public/packs-test/public/assets# Ignore yarn files/yarn-error.logyarn-debug.log*.yarn-integrity# Ignore uploaded files in development/storage/*!/storage/.keep/public/uploads

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

함께 쓰는 템플릿

다른 템플릿 해설