Rails which files to ignore for GIT
Ruby on-RailsGitRuby on-Rails Problem Overview
I created a GIT repo, locally. I now see a bunch of files i rather ignore for GIT check-in. This brings me to the question: is there any default .gitignore for Rails? Any best practices?
I think of tmp and log for sure. But are there any other files or folders i should consider?
Ruby on-Rails Solutions
Solution 1 - Ruby on-Rails
Github has sample .gitignore
files for almost any kind of project known to humanity.
Check out the repo: https://github.com/github/gitignore
Solution 2 - Ruby on-Rails
this is a gitignore from a relatively large Rails 3.2 app (created with Rails 3.1)
/.bundle
/db/*.sqlite3
/log/*.log
/tmp
config/database.yml
config/google_analytics.yml
.DS_Store
/nbproject/
public/assets/**
just the basic gitignore which comes with rails and added some developer specific stuff like Netbeans project stuff, the .DS_Store from OS X
and we don't like passwords in our repository, so we add all yml files with passwords to gitignore
we also added public/assets/** since we deploy our apps with capistrano and generate the assets during the deploy and push them to amazon
Solution 3 - Ruby on-Rails
.git/info/exclude If you wish the exclude patterns based on repositories , you may instead put them in a file in that specific repository named .git/info/exclude or core.excludesfile
.gitignore is used to add files which you don't want to be tracked. If the file is already being tracked and you want to add to .gitignore. run git rm --cached filename
Solution 4 - Ruby on-Rails
Make use of this GITIGNORE.IO
### Rails ###
*.rbc
capybara-*.html
.rspec
/log
/tmp
/config/database.yml
/db/*.sqlite3
/db/*.sqlite3-journal
/public/system
/coverage/
/spec/tmp
**.orig
rerun.txt
pickle-email-*.html
# TODO Comment out these rules if you are OK with secrets being uploaded to the repo
config/initializers/secret_token.rb
config/secrets.yml
## Environment normalisation:
/.bundle
/vendor/bundle
# these should all be checked in to normalise 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
*.bowerrc
bower.json
#Ignore pow enironment settings
.powenv
Solution 5 - Ruby on-Rails
Rails already generate a .gitignore file for you with good defaults. You think right, in fact the .gitignore generated by rails already ignores tmp and log file (and the DBs too).