Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Heroku pull private github repository

Tags:

git

github

heroku

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:[email protected]/me/my_gem.git
error: The requested URL returned error: 401 while accessing https://user:[email protected]/me/my_gem.git/info/refs
Git error: command `git clone 'https://user:[email protected]/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://[email protected]/me/my_gem.git
Password:

Heroku stall and prompt for a password.

On my local machine both:

git clone https://user:[email protected]/me/my_gem.git

and

git clone https://[email protected]/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
like image 520
Jacob Avatar asked Oct 30 '12 11:10

Jacob


2 Answers

Heroku runs an older Git version, which unfortunately doesn't fully support the auth part of the URLs.

You can work around this by adding the dummy password supplied by GitHub. So instead of using:

https://#{github_oauth_token}@github.com/me/my_gem.git

Use:

https://#{github_oauth_token}:[email protected]/me/my_gem.git
like image 159
bergie Avatar answered Oct 09 '22 18:10

bergie


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 :-)

like image 2
Jacob Avatar answered Oct 09 '22 20:10

Jacob