【问题标题】:Revert to a gem version based on commit根据提交恢复到 gem 版本
【发布时间】:2013-08-14 19:32:09
【问题描述】:

三天前我将它添加到我的 Gemfile 中:

gem 'bootstrap-sass', git: 'https://github.com/thomas-mcdonald/bootstrap-sass', branch: '3'

今天我跑了bundle update,gem 更新了,结果很多测试都被破坏了。

有没有办法可以恢复到三天前的宝石?我可以查看提交,但我不知道我是否可以回到某个提交。

【问题讨论】:

    标签: ruby-on-rails ruby git gem


    【解决方案1】:

    Gemfile.lock 存储使用的修订,因此如果您查看三天前的代码,请查看那里。它应该看起来像这样:

    GIT
      remote: git://github.com/datamapper/dm-core.git
      revision: 7cc4c145329e81d8b373a37694d050aa197c3699
      branch: release-1.2
      specs:
        dm-core (1.2.1)
          addressable (~> 2.3, >= 2.3.5)
    

    只需将当前Gemfile 中的:branch 替换为上述revision SHA 并运行bundle install

    【讨论】:

      【解决方案2】:

      您可以将 Gemfile 指向 Git 存储库的特定提交/分支/标签:

      gem 'rails', :git => 'git://github.com/rails/rails.git', :ref => '4aded'
      gem 'rails', :git => 'git://github.com/rails/rails.git', :branch => '2-3-stable'
      gem 'rails', :git => 'git://github.com/rails/rails.git', :tag => 'v2.3.5'
      

      别忘了重新运行bundle install

      来源:Bundler git docs

      【讨论】:

      • 提问者已经这样做了。他们的问题是如何确定之前使用的 ref。
      • @AbeVoelker 我可以查看提交,但 我不知道我是否可以回到某个提交我会解释想要使用有问题的 gem 的特定提交;而不是 OPs 自己的项目中的提交。但是你提到Gemfile.lock 的方式也可以。
      【解决方案3】:

      如果此更新包含在某个提交中,您只需通过“git revert”命令进行与该提交相反的操作

      git revert <that commit hash>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-04-08
        • 2011-08-25
        • 2019-08-25
        • 2020-10-17
        • 2013-06-26
        • 2014-03-31
        • 1970-01-01
        • 2011-10-11
        相关资源
        最近更新 更多