简体   繁体   中英

Revert to a gem version based on commit

I added this to my Gemfile three days ago:

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.

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. 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 .

You can point your Gemfile to a specific commit/branch/tag of a Git repo:

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

Source: Bundler git docs

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

git revert <that commit hash>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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