ruby - Gemfile.lock 应该包含在 .gitignore 中吗?

标签 ruby git version-control bundler gemfile

我对 bundler 及其生成的文件有点陌生。我有一份来自 GitHub 的 git repo 的副本,很多人都在贡献它,所以我很惊讶地发现 bundler 创建了一个在 repo 中不存在且不在 .gitignore列表。

因为我已经 fork 了它,我知道将它添加到 repo 不会破坏主 repo 的任何东西,但是如果我做一个 pull request,它会导致问题吗?

Gemfile.lock 应该包含在存储库中吗?

最佳答案

2022 年更新 来自 TrinitronX

Fast-forward to 2021 and now Bundler docs [web archive] now say to commit the Gemfile.lock inside a gem... ¯_(ツ)_/¯ I guess it makes sense for developers and ease of use when starting on a project. However, now CI jobs need to be sure to remove any stray Gemfile.lock files to test against other versions.

遗留答案 ~2010

假设您不是在编写 ruby​​gem,Gemfile.lock 应该在您的存储库中。它用作所有必需的 gem 及其依赖项的快照。这样,打包程序就不必在每次部署时重新计算所有的 gem 依赖项等。

下面是 cowboycoded 的评论:

If you are working on a gem, then DO NOT check in your Gemfile.lock. If you are working on a Rails app, then DO check in your Gemfile.lock.

这是一个不错的 article解释什么是锁定文件。

关于ruby - Gemfile.lock 应该包含在 .gitignore 中吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4151495/

相关文章:

git - .gitignore、git add 和文件神秘消失

php - 在 Git 中维护 "version for the server"的正确方法是什么 - 仅更改配置文件?

ruby-on-rails - 带有 cron 的可安装引擎(每当 gem 时)

ruby-on-rails - 如何使用 strong_parameters 允许除 user_id 之外的所有属性?

ruby-on-rails - 如何在 OS X 上使用 ruby​​ 2.3 为 mysql2 gem 解析 "incompatible library version"?

git - git add 和 git commit -a 的区别

ruby-on-rails - 编辑文本时 Rails 控制台运行速度异常缓慢

git - Bitnami + Redmine + Git 不工作

Git on godaddy - 找不到 git-upload-pack

git - 任何源代码控制系统都可以处理基于每个客户端的分支代码吗?