Heroku拉私有github存储库

Jac*_*cob 12 git github heroku

我尝试了不同的方法在Rails应用程序Gemfile中使用Github私有存储库引用.

1) Gemfile:
gem 'my_gem', :git => "https://#{github_user}:#{github_pw}@github.com/me/my_gem.git"
Run Code Online (Sandbox Code Playgroud)

'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
Run Code Online (Sandbox Code Playgroud)

然后我发现了这篇文章https://help.github.com/articles/creating-an-oauth-token-for-command-line-use并创建了一个OAuth令牌.

2) Gemfile:
gem 'my_gem', :git => "https://#{github_oauth_token}@github.com/me/my_gem.git"
Run Code Online (Sandbox Code Playgroud)

'git push heroku'的结果:

Fetching https://0123456789abcdef0123456789abcdef01234567@github.com/me/my_gem.git
Password:
Run Code Online (Sandbox Code Playgroud)

Heroku失速并提示输入密码.

在我的本地机器上:

git clone https://user:pw@github.com/me/my_gem.git
Run Code Online (Sandbox Code Playgroud)

git clone https://0123456789abcdef0123456789abcdef01234567@github.com/me/my_gem.git
Run Code Online (Sandbox Code Playgroud)

作品perfekt!

本地:

# git --version
git version 1.7.9.5
Run Code Online (Sandbox Code Playgroud)

Heroku的:

# heroku run git --version
git version 1.7.0
Run Code Online (Sandbox Code Playgroud)

ber*_*gie 6

Heroku运行较旧的Git版本,遗憾的是它并不完全支持URL的auth部分.

您可以通过添加GitHub提供的虚拟密码来解决此问题.所以不要使用:

https://#{github_oauth_token}@github.com/me/my_gem.git
Run Code Online (Sandbox Code Playgroud)

使用:

https://#{github_oauth_token}:x-oauth-basic@github.com/me/my_gem.git
Run Code Online (Sandbox Code Playgroud)


Jac*_*cob 2

Heroku 的 git(版本 1.7)不支持使用电子邮件作为 Github 存储库的用户名。

您必须使用您的 Github 用户名。

此外,Heroku 的 git 不支持使用 oauth 令牌。

希望 Heroku 能够尽快升级他们的 git,这样他们就可以继续让我的生活更轻松:-)