55

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?

Roger
  • 7,535
  • 5
  • 41
  • 63
  • 3
    Rails should have generated a `.gitignore` file for you with the most common non-source-control files included already – Gareth Mar 08 '12 at 10:45

6 Answers6

83

Github has sample .gitignore files for almost any kind of project known to humanity in their github/gitignore repository.

There is one specifically for Rails: Rails.gitignore

BinaryButterfly
  • 18,137
  • 13
  • 50
  • 91
Ekin Koc
  • 2,996
  • 20
  • 24
13

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

beanie
  • 1,428
  • 9
  • 14
2

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
errakeshpd
  • 2,544
  • 2
  • 28
  • 35
2

.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

Bijendra
  • 9,467
  • 8
  • 39
  • 66
1

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).

Aldo 'xoen' Giambelluca
  • 12,075
  • 7
  • 33
  • 39
0

Here's the direct link to the Rails gitignore file. It is up I found this by a simple google search.

You can modify it as per your project/tools settings. I had to add .idea/ to it which is automatically generated by Rubymine.

mansoor.khan
  • 2,309
  • 26
  • 39