Gemfile.lock 应该包含在 .gitignore 中吗? [英] Should Gemfile.lock be included in .gitignore?

查看:31
本文介绍了Gemfile.lock 应该包含在 .gitignore 中吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 bundler 及其生成的文件有点陌生.我有一份来自 GitHub 的 git repo 副本,该副本由许多人提供,因此我惊讶地发现 bundler 创建了一个不存在于 repo 中且不在 .gitignore列表.

I'm sort of new to bundler and the files it generates. I have a copy of a git repo from GitHub that is being contributed to by many people so I was surprised to find that bundler created a file that didn't exist in the repo and wasn't in the .gitignore list.

既然我已经分叉了它,我知道将它添加到 repo 不会破坏主 repo 的任何内容,但是如果我执行拉取请求,它会导致问题吗?

Since I have forked it, I know adding it to the repo won't break anything for the main repo, but if I do a pull request, will it cause a problem?

是否应该将 Gemfile.lock 包含在存储库中?

Should Gemfile.lock be included in the repository?

推荐答案

2021年的简单回答:Gemfile.lock 也应该在 Rubygems 的版本控制中.接受的答案现在已经 11 岁了.

Simple answer in the year 2021: Gemfile.lock should be in the version control also for Rubygems. The accepted answer is now 11 years old.

这里有一些推理(摘自评论):

Some reasoning here (cherry-picked from comments):

@josevalim https://github.com/heartcombo/devise/pull/3147#issuecomment-52193788

@josevalim https://github.com/heartcombo/devise/pull/3147#issuecomment-52193788

Gemfile.lock 应该保留在存储库中,因为贡献者和开发人员应该能够分叉项目并使用保证工作的版本运行它.

The Gemfile.lock should stay in the repository because contributors and developers should be able to fork the project and run it using versions that are guaranteed to work.

@rafaelfranca https://github.com/rails/rails/pull/18951#issuecomment-74888396

@rafaelfranca https://github.com/rails/rails/pull/18951#issuecomment-74888396

我认为即使是插件也不要忽略锁定文件.

I don't think it is a good idea to ignore the lock file even for plugins.

这意味着一个 "git clone;捆;耙式测试"序列不能保证通过,因为您的数十个依赖项之一已升级并使您的代码中断.此外,正如@chancancode 所说,将其一分为二要困难得多.

This mean that a "git clone; bundle; rake test" sequence is not guarantee to be passing because one of yours dozens of dependencies were upgraded and made your code break. Also, as @chancancode said, it make a lot harder to bisect.

Rails 在 git 中也有 Gemfile.lock:

Also Rails has Gemfile.lock in git:

这篇关于Gemfile.lock 应该包含在 .gitignore 中吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆