Ruby-on-rails Rails 要忽略 GIT 的哪些文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9616362/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 02:59:47  来源:igfitidea点击:

Rails which files to ignore for GIT

ruby-on-railsgit

提问by Roger

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?

我在本地创建了一个 GIT 存储库。我现在看到一堆文件,我宁愿忽略 GIT 签入。这让我想到了一个问题:Rails 有任何默认的 .gitignore 吗?任何最佳实践?

I think of tmpand logfor sure. But are there any other files or folders i should consider?

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

回答by Ekin Koc

Github has sample .gitignorefiles for almost any kind of project known to humanity.

Github 拥有.gitignore几乎所有人类已知项目的示例文件。

Check out the repo: https://github.com/github/gitignore

查看 repo:https: //github.com/github/gitignore

回答by beanie

this is a gitignore from a relatively large Rails 3.2 app (created with Rails 3.1)

这是来自相对较大的 Rails 3.2 应用程序的 gitignore(使用 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

只是 Rails 附带的基本 gitignore 并添加了一些特定于开发人员的内容,例如 Netbeans 项目内容,OS X 中的 .DS_Store

and we don't like passwords in our repository, so we add all yml files with passwords to gitignore

并且我们不喜欢存储库中的密码,因此我们将所有带有密码的 yml 文件添加到 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

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

回答by Bijendra

.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

.git/info/exclude 如果您希望基于存储库的排除模式,您可以将它们放在名为 .git/info/exclude 或 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

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

回答by errakeshpd

Make use of this GITIGNORE.IO

利用这个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

回答by Aldo 'xoen' Giambelluca

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

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