Docs header transparent bg

Gems from git repositories

Bundler adds the ability to use gems directly from git repositories. Setting them up is as easy as adding a gem to your Gemfile. Using the very latest version of a gem (or even a fork) is just as easy as using an official release.
Because RubyGems lacks the ability to handle gems from git, any gems installed from a git repository will not show up in gem list. They will, however, be available after running Bundler.setup.
Specify that a gem should come from a git repository with a .gemspec at its root
gem 'nokogiri', :git => 'https://github.com/tenderlove/nokogiri.git'

If there is no .gemspec at the root of a git repository, you must specify a version that bundler should use when resolving dependencies
gem 'deep_merge', '1.0', :git => 'https://github.com/peritor/deep_merge.git'

Specify that a git repository containing multiple .gemspec files should be treated as a gem source
git 'https://github.com/rails/rails.git' do
  gem 'railties'
  gem 'action_pack'
  gem 'active_model'
end

Specify that a git repository should use a particular ref, branch, or tag
:git => 'https://github.com/rails/rails.git', :ref => '4aded'
:git => 'https://github.com/rails/rails.git', :branch => '2-3-stable'
:git => 'https://github.com/rails/rails.git', :tag => 'v2.3.5'

Specifying a ref, branch, or tag for a git repository specified inline works exactly the same way
gem 'nokogiri', :git => 'https://github.com/tenderlove/nokogiri.git', :ref => '0eec4'

Bundler can use HTTP(S), SSH, or git
gem 'nokogiri', :git => 'https://github.com/tenderlove/nokogiri.git'
gem 'nokogiri', :git => 'git@github.com:tenderlove/nokogiri.git'
gem 'nokogiri', :git => 'git://github.com/tenderlove/nokogiri.git'

If you are getting your gems from a public GitHub repository, you can use the shorthand
gem 'nokogiri', :github => 'tenderlove/nokogiri'
If the repository name is the same as the GitHub account hosting it, you can omit it
gem 'rails', :github => 'rails'
NB: This shorthand is insecure in versions of Bundler prior to 2.0! Use HTTPS instead
gem 'rails', :git => 'https://github.com/rails/rails'
Alternatively, you can specify a full commit hash
gem 'rails', :github => 'rails', :ref => 'a9752dcfd15bcddfe7b6f7126f3a6e0ba5927c56'

Security

http:// and git:// URLs are insecure, and should be avoided if at all possible. These protocols are unauthenticated, so a man-in-the-middle attacker can tamper with the code and compromise your system. Note that the :github shortcut translates to a git:// URL in pre-2.0 versions.