Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 991
dangerousdave Avatar asked Sep 04 '11 18:09

dangerousdave


People also ask

What is the difference between Gemfile and Gemfile lock?

The Gemfile is where you specify which gems you want to use, and lets you specify which versions. The Gemfile. lock file is where Bundler records the exact versions that were installed. This way, when the same library/project is loaded on another machine, running bundle install will look at the Gemfile.

Should Gemfile lock be checked in?

The Gem Development guide says that the Gemfile. lock file "should always be checked into version control." However, this is NOT true for Gems. For Applications, like your Rails apps, Sinatra apps, etc., it is true. The same does not go for Gems.

Is Gemfile lock automatically generated?

Gemfile. lock is automatically generated when you run bundle install or bundle update . It should never be edited manually.


1 Answers

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 
like image 105
VonC Avatar answered Sep 16 '22 23:09

VonC