变基时 Gemfile.lock 发生冲突

发布于 2024-12-02 22:09:08 字数 95 浏览 0 评论 0原文

在 Git 中变基时,人们有什么策略来解决 Gemfile.lock 冲突?

我在最近的一个项目中不得不经常这样做,这不仅很乏味,而且并不总是清楚如何进行合并。

What strategies do people have for resolving Gemfile.lock conflicts while rebasing in Git?

I am having to do this a lot in a recent project, and not only is it tedious, it's not always clear how to do the merge.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

旧人 2024-12-09 22:09:08

您可以通过合并驱动程序在每次合并时重新锁定它(我通常使用它在合并期间始终保留文件的本地版本)。

请参阅自动合并 Gemfile.lock” href="http://bitfission.com/" rel="noreferrer">威尔·莱因韦伯:

您所要做的就是运行bundle lock(在Rail3中已过时)bundle install来获取bundler重新锁定然后添加它并继续您的变基。

首先是您的 ~/.gitconfig 文件。
在这里,我们将为其提供一种新的合并策略,该策略将重新锁定 gemfile。
将其添加到末尾:

[merge "gemfilelock"]
  name = relocks the gemfile.lock
  driver = bundle install

接下来,我们必须告诉 git 使用 Gemfile.lock 的新策略,我们使用 gitattributes 来实现这一点。
您可以将其放入 project/.git/info/attributesproject/.gitattributes

Gemfile.lock merge=gemfilelock

you could relock it on every merge, through a merge driver (that I usually use to always keep the local version of a file during a merge).

See "Auto Merge Gemfile.lock" from Will Leinweber:

All you have to do is run bundle lock (obsolete in Rail3) bundle install to get bundler to relock then add that and continue your rebase.

First is your ~/.gitconfig file.
Here we're going to give it a new merge strategy, one that will just relock the gemfile.
Add this to the end:

[merge "gemfilelock"]
  name = relocks the gemfile.lock
  driver = bundle install

Next up, we have to tell git to use our new strategy for Gemfile.lock, and we do that with gitattributes.
You can either put this in project/.git/info/attributes or project/.gitattributes.

Gemfile.lock merge=gemfilelock
悸初 2024-12-09 22:09:08

使用 git log Gemfile.lock 查找先前提交的哈希值。然后运行 ​​git checkout abcde Gemfile.lock 来恢复。之后您的 bundle install 命令应该可以工作。

Use git log Gemfile.lock to find the hash of a previous commit. Then run git checkout abcde Gemfile.lock to revert back. Your bundle install command should work after that.

黯淡〆 2024-12-09 22:09:08

您可以使用此脚本自动设置 git 存储库以使用提到的合并解析策略: https://gist .github.com/itspriddle/5548930

或者,您可以使用 tpope 的连接在 git pull 后自动执行此操作(并运行数据库迁移):https://github.com/tpope/hookup

You can use this script to automatically set up a git repository to use the mentioned merge resolution strategy: https://gist.github.com/itspriddle/5548930

Alternatively, you can use tpope's hookup to do this (and run database migrations) automatically after git pulls: https://github.com/tpope/hookup

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文