git 在 Heroku 上与 Rails 一起使用的好的 .gitignore 是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2542353/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is a good .gitignore to use with Rails on Heroku?
提问by Victor
What is a good .gitignore to use with Rails on Heroku?
在 Heroku 上与 Rails 一起使用的好的 .gitignore 是什么?
*.log
*.sqlite3
what else?
还有什么?
回答by Dan McNevin
This is pretty similar to: Rails: exclude anything from version control?Here is my answer from that.
这非常类似于:Rails:从版本控制中排除任何内容?这是我的回答。
DHH just posted on Twitterthat there will be a default .gitignorein Rails 3, which includes:
DHH 刚刚在 Twitter 上发布说Rails 3中将有一个默认的 .gitignore,其中包括:
db/*.sqlite3
log/*.log
tmp/**/*
This is usually what I exclude. Some people also like to exclude the database.yml file if it's going on a public repo and you don't want to expose your database passwords.
这通常是我排除的。有些人还喜欢排除 database.yml 文件,如果它在公共存储库中进行并且您不想暴露您的数据库密码。
回答by Shaliko Usubov
https://github.com/github/gitignore/blob/master/Rails.gitignore
https://github.com/github/gitignore/blob/master/Rails.gitignore
*.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 this rule if you are OK with secrets being uploaded to the repo config/initializers/secret_token.rb # Only include if you have production secrets in this file, which is no longer a Rails default # config/secrets.yml # dotenv # TODO Comment out this rule if environment variables can be committed .env ## 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 *.bowerrc bower.json # Ignore pow environment settings .powenv # Ignore Byebug command history file. .byebug_history
*.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 this rule if you are OK with secrets being uploaded to the repo config/initializers/secret_token.rb # Only include if you have production secrets in this file, which is no longer a Rails default # config/secrets.yml # dotenv # TODO Comment out this rule if environment variables can be committed .env ## 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 *.bowerrc bower.json # Ignore pow environment settings .powenv # Ignore Byebug command history file. .byebug_history
回答by Franck Verrot
Keep in mind that Heroku's slug compiler has a very similar feature using a file named .slugignore
. This file syntax is roughlythe same as in .gitignore
.
请记住,Heroku 的 slug 编译器使用名为.slugignore
. 这个文件的语法是大致一样.gitignore
。
So you can continue working as usual (ie: storing PSD files, spreadsheets and other common files) but remove them at runtime onHeroku to lower the slug's size (< 20MB sounds good).
因此,您可以继续照常工作(即:存储 PSD 文件、电子表格和其他常见文件),但在运行时在Heroku上删除它们以降低 slug 的大小(< 20MB 听起来不错)。
回答by djGrill
On Heroku, the best starting option is:
在 Heroku 上,最好的启动选项是:
db/
log/
test/
tmp/
回答by SnapShot
There is a project on Github dedicated to storing accurate gitignore files for different languages, editors, etc. While the project does not currently have an entry specific to Heroku, you might still find it useful to review. The project is hereand the Rails .gitignore is here.
Github 上有一个项目专门用于为不同语言、编辑器等存储准确的 gitignore 文件。虽然该项目目前没有特定于 Heroku 的条目,但您可能仍然会发现查看它很有用。该项目在这里,Rails .gitignore 在这里。
FYI, I first found out about this project from thisStack Overflow question.
仅供参考,我首先从这个Stack Overflow 问题中了解到这个项目。