See all articles
Do not push by force to gem repo - Ruby Developer’s Notes

Do not push by force to gem repo - Ruby Developer’s Notes

Here's a short tip for all programmers out there: do not push by force to gem repo. Why?

If you maintain a gem (or a fork specifically for your app), do not push by force to the `master` branch or any other branch that can be referenced in the app's Gemfile. It may cause you some trouble.

If your Shortgem is referenced via git, you can have a problem when someone (possibly you) pushes by force. When you push by force, your `Gemfile.lock` needs to be updated to reflect the commit change. Otherwise, you will get an error: `fatal: Could not parse object 'some_commit_id'`.

To solve it, you need to re-generate the `Gemfile.lock`.

The easiest way to do it:

1. Comment the problematic gem in the `Gemfile`

2. Run `bundle install`

3. Uncomment the gem from the first step

4. Run `bundle install` once again.

Always ensure that shared branches (such as `master` or `develop`) are merge-only and set as protected on GitHub or GitLab. Do you have any questions about this issue? Or any other IT-related problems? Contact iRonin for assistance!

Today's Developer's Notes were shared by Łukasz, a Ruby on Rails developer. Interested to learn more from experts at iRonin - Ruby on Rails Development Company? Stay tuned for more tips and tricks in the near future!

Read Similar Articles