I have tryed different approaches to use a Github private repository reference in a Rails application Gemfile.
1) Gemfile:
gem 'my_gem', :git => "https://#{github_user}:#{github_pw}@github.com/me/my_gem.git"
Result from ‘git push heroku’:
Fetching https://user:pw@github.com/me/my_gem.git
error: The requested URL returned error: 401 while accessing https://user:pw@github.com/me/my_gem.git/info/refs
Git error: command `git clone 'https://user:pw@github.com/me/my_gem.git' "/tmp/build_2wxmqutch8gy7/vendor/bundle/jruby/1.9/cache/bundler/git/my_gem-929bddeee3dd4a564c2689e189190073df01431e" --bare --no-hardlinks` in directory /tmp/build_2wxmqutch8gy7 has failed.
Dependencies installed
Then I found this article https://help.github.com/articles/creating-an-oauth-token-for-command-line-use and created an OAuth token.
2) Gemfile:
gem 'my_gem', :git => "https://#{github_oauth_token}@github.com/me/my_gem.git"
Result from ‘git push heroku’:
Fetching https://0123456789abcdef0123456789abcdef01234567@github.com/me/my_gem.git
Password:
Heroku stall and prompt for a password.
On my local machine both:
git clone https://user:pw@github.com/me/my_gem.git
and
git clone https://0123456789abcdef0123456789abcdef01234567@github.com/me/my_gem.git
works perfekt!
Local:
# git --version
git version 1.7.9.5
Heroku:
# heroku run git --version
git version 1.7.0
Heroku’s git (version 1.7) doesn’t support using e-mail as username for Github’s repositories.
You must use your Github username.
Also, Heroku’s git doesn’t support using an oauth token.
Hopefully Heroku will upgrade their git soon, so they can continue making my life easier 🙂