Rails文件要忽略GIT

时间:2012-03-08 10:43:10

标签: ruby-on-rails git

我在本地创建了一个GIT仓库。我现在看到一堆文件我宁愿忽略GIT签到。这让我想到了一个问题:Rails有没有默认的.gitignore?任何最佳做法?

我肯定会想到 tmp log 。但是我应该考虑其他任何文件或文件夹吗?

5 个答案:

答案 0 :(得分:71)

Github为人类已知的几乎任何类型的项目提供了样本.gitignore文件。

查看回购:https://github.com/github/gitignore

答案 1 :(得分:12)

这是来自相对较大的Rails 3.2应用程序(使用Rails 3.1创建)的gitignore

/.bundle
/db/*.sqlite3
/log/*.log
/tmp
config/database.yml
config/google_analytics.yml
.DS_Store
/nbproject/
public/assets/**

只是带有rails的基本gitignore,并添加了一些开发人员特定的东西,比如Netbeans项目的东西,来自OS X的.DS_Store

我们不喜欢我们的存储库中的密码,因此我们将所有带密码的yml文件添加到gitignore

我们还添加了public / assets / **,因为我们使用capistrano部署我们的应用程序并在部署期间生成资产并将其推送到亚马逊

答案 2 :(得分:2)

的.git /信息/排除 如果您希望基于存储库的排除模式,您可以将它们放在名为.git / info / exclude或core.excludesfile

的特定存储库中的文件中。

.gitignore用于添加您不想跟踪的文件。 如果文件已被跟踪,并且您要添加到.gitignore。 运行git rm --cached filename

答案 3 :(得分:2)

使用此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

答案 4 :(得分:1)

Rails已经为您生成了一个具有良好默认值的.gitignore文件。你认为是对的,实际上rails生成的.gitignore已经忽略了tmp和日志文件(以及数据库)。