Which files should be inserted into . gitignore in a Rails project?

Asked

Viewed 397 times

2

I’m starting in Git and also in Ruby on Rails. I created a new project using rails new myapp -d mysql and added to my Github repository. When creating the project Rails generates multiple files.

So far so good, but it turns out that some files, which contains password from the database - config/database.yml (for example) went up to the repository.

I would like to know what files are recommended that I put in. gitignore, so I don’t expose my security information, or unnecessary files that are usually not added to the repository.

1 answer

2


Language-independent for my projects I always start with the Github template. And edit based on my preferences.

You can find Ruby’s here: https://github.com/github/gitignore/blob/master/Ruby.gitignore

Below the contents of the file in case of Dead link.

*.gem
*.rbc
/.config
/coverage/
/InstalledFiles
/pkg/
/spec/reports/
/test/tmp/
/test/version_tmp/
/tmp/

## Specific to RubyMotion:
.dat*
.repl_history
build/

## Documentation cache and generated files:
/.yardoc/
/_yardoc/
/doc/
/rdoc/

## Environment normalisation:
/.bundle/
/vendor/bundle
/lib/bundler/man/

# for a library or gem, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# Gemfile.lock
# .ruby-version
# .ruby-gemset

# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
.rvmrc

And here to Rails: https://github.com/github/gitignore/blob/master/Rails.gitignore

You can add the config/database.yml no . gitignore so that it is ignored, if it is a public repository and/or you do not want to expose your database password.

*.rbc
capybara-*.html
.rspec
/log
/tmp
/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 environment settings
.powenv
  • 2

    You can use https://www.gitignore.io/ to choose various languages/frameworks/Ides and get a single . gitignore concatenated.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.