简体   繁体   English

根据提交还原为gem版本

[英]Revert to a gem version based on commit

I added this to my Gemfile three days ago: 我三天前将其添加到我的Gemfile中:

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

Today I ran bundle update , the gem got updated, and a lot of tests are broken as a result. 今天,我运行了bundle update ,gem得到了更新,结果很多测试都被破坏了。

Is there a way I can revert back to the gem as it were three days ago? 有什么方法可以恢复到三天前的状态吗? I can look at the commits, but I don't know if I can go back to a certain commit. 我可以查看提交,但是我不知道是否可以返回到某个提交。

Gemfile.lock stores the revision used, so if you check out your code from three days ago look there. Gemfile.lock存储使用的修订版,因此,如果您三天前检出代码,请在那里查看。 It should look something like this: 它看起来应该像这样:

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)

Just replace :branch in your current Gemfile with the above revision SHA and run bundle install . 只需将当前Gemfile :branch替换为上述revision SHA并运行bundle install

You can point your Gemfile to a specific commit/branch/tag of a Git repo: 您可以将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'

Don't forget to re-run bundle install 不要忘记重新运行bundle install

Source: Bundler git docs 资料来源: Bundler git docs

如果此更新包含在某些提交中,则可以通过'git revert'命令对该提交进行相反的操作

git revert <that commit hash>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM