我尝试了不同的方法在 Rails 应用程序Gemfile中使用 Github 私有存储库引用。
1) Gemfile:
gem 'my_gem', :git => "https://#{github_user}:#{github_pw}@github.com/me/my_gem.git"
'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
然后我找到了这篇文章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"
'git push heroku' 的结果:
Fetching https://0123456789abcdef0123456789abcdef01234567@github.com/me/my_gem.git
Password:
Heroku 停止并提示输入密码。
在我的本地机器上:
git clone https://user:pw@github.com/me/my_gem.git
和
git clone https://0123456789abcdef0123456789abcdef01234567@github.com/me/my_gem.git
工作完美!
当地的:
# git --version
git version 1.7.9.5
赫罗库:
# heroku run git --version
git version 1.7.0