dangerousdave
dangerousdave

Reputation: 6418

Conflicts in Gemfile.lock while rebasing

What strategies do people have for resolving Gemfile.lock conflicts while rebasing in Git?

I am having to do this a lot in a recent project, and not only is it tedious, it's not always clear how to do the merge.

Upvotes: 29

Views: 5892

Answers (3)

indirect
indirect

Reputation: 3490

You can use this script to automatically set up a git repository to use the mentioned merge resolution strategy: https://gist.github.com/itspriddle/5548930

Alternatively, you can use tpope's hookup to do this (and run database migrations) automatically after git pulls: https://github.com/tpope/hookup

Upvotes: 1

Ryan Buckley
Ryan Buckley

Reputation: 121

Use git log Gemfile.lock to find the hash of a previous commit. Then run git checkout abcde Gemfile.lock to revert back. Your bundle install command should work after that.

Upvotes: 4

VonC
VonC

Reputation: 1330102

you could relock it on every merge, through a merge driver (that I usually use to always keep the local version of a file during a merge).

See "Auto Merge Gemfile.lock" from Will Leinweber:

All you have to do is run bundle lock (obsolete in Rail3) bundle install to get bundler to relock then add that and continue your rebase.

First is your ~/.gitconfig file.
Here we're going to give it a new merge strategy, one that will just relock the gemfile.
Add this to the end:

[merge "gemfilelock"]
  name = relocks the gemfile.lock
  driver = bundle install

Next up, we have to tell git to use our new strategy for Gemfile.lock, and we do that with gitattributes.
You can either put this in project/.git/info/attributes or project/.gitattributes.

Gemfile.lock merge=gemfilelock

Upvotes: 23

Related Questions