schmijos
schmijos

Reputation: 8695

Gemfile: Difference Between branch and ref in a github Reference

In the Gemfile it's possible to refer a gem hosted on github:

gem 'spree', github: 'spree/spree', branch: '2-3-stable'
gem 'spree_gateway', github: 'spree/spree_gateway', ref: '2-1-stable'

The Gemfile manpage describes three attributes for git: branch, ref and tag. What's the difference between ref and branch? And how does bundler handle the gems differently depending on the attribute?

This especially seems to be interesting because you can only use one of the attributes at a time.

Upvotes: 5

Views: 2369

Answers (1)

Nick Veys
Nick Veys

Reputation: 23939

With branch, you're just specifying the git branch to pull from. If you did a bundle up <gem> when targeting a branch, it would update to the tip of that branch.

The ref is really nailing it down to an individual commit. You wouldn't give a "human-readable" name as you did in your question, you'd do something like:

gem 'something', github: 'someone/something', ref: '832e76a9'

And now you've pinned it to that ref. If you did a bundle up something, it wouldn't change that gem (it may update its dependencies though).

Upvotes: 12

Related Questions