GIT要忽略的Rails文件

6za6bjd0  于 2023-06-20  发布在  Git
关注(0)|答案(5)|浏览(125)

我在本地创建了一个GIT repo。我现在看到一堆文件,我宁愿忽略GIT签入。这就引出了一个问题:有没有default.gitignore for Rails?有什么最佳做法吗?
我肯定会想到 tmplog。但是有没有其他的文件或文件夹我应该考虑?

0ejtzxu1

0ejtzxu11#

Github在their github/gitignore存储库中提供了几乎所有人类已知项目的.gitignore示例文件。
有一个是专门针对Rails的:Rails.gitignore

vof42yt1

vof42yt12#

这是一个来自一个相对较大的Rails3.2应用程序(用Rails3.1创建)的gitignore

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

这只是一个基本的gitignore,它附带了rails,并添加了一些开发人员特定的东西,如Netbeans项目的东西,OS X的.DS_Store
并且我们不喜欢在仓库中使用密码,所以我们将所有带有密码的yml文件添加到gitignore
我们还添加了public/assets/**,因为我们使用capistrano部署我们的应用程序,并在部署期间生成资产并将其推送到amazon

avkwfej4

avkwfej43#

.git/info/exclude如果您希望排除模式基于存储库,您可以将它们放在特定存储库中的一个文件中,该文件名为.git/info/exclude或core.excludesfile
.gitignore用于添加您不想被跟踪的文件。如果文件已被跟踪,并且您希望添加到. gitignore。运行git rm --cached filename

gv8xihay

gv8xihay4#

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

ddrv8njm5#

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

相关问题