【问题标题】:Conflicts in Gemfile.lock while rebasing变基时 Gemfile.lock 中的冲突
【发布时间】:2011-11-10 04:56:22
【问题描述】:

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

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

【问题讨论】:

  • 这个问题发生在我身上,因为我对我所在的分支感到困惑。解决方法是拍我的额头,然后切换回正确的分支,Gemfile.lock 冲突冲突错误就消失了。

标签: ruby-on-rails-3 git bundler conflict rebase


【解决方案1】:

您可以通过合并驱动程序(我通常用于always keep the local version of a file during a merge)在每次合并时重新锁定它。

参见Will Leinweber中的“Auto Merge Gemfile.lock”:

您所要做的就是运行 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

【讨论】:

【解决方案2】:

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

【讨论】:

    【解决方案3】:

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

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

    【讨论】:

      猜你喜欢
      • 2017-03-04
      • 2014-12-14
      • 1970-01-01
      • 2019-01-22
      • 1970-01-01
      • 2020-08-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多