【问题标题】:Heroku pull private github repositoryHeroku 拉取私有 github 仓库
【发布时间】:2012-10-19 17:36:27
【问题描述】:

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

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:

# heroku run git --version
git version 1.7.0

【问题讨论】:

    标签: git heroku github


    【解决方案1】:

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

    您可以通过添加 GitHub 提供的 dummy password 来解决此问题。所以不要使用:

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

    用途:

    https://#{github_oauth_token}:x-oauth-basic@github.com/me/my_gem.git
    

    【讨论】:

    • 有没有办法访问 github 组织拥有的私有仓库?我正在尝试让 bower 通过 bower.json 获取一个私人仓库。
    • 这应该适用于个人和组织存储库,只要您有权使用您的 OAuth 令牌所用于的帐户访问它们
    【解决方案2】:

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

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

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

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

    【讨论】:

    猜你喜欢
    • 2012-08-13
    • 2018-06-16
    • 2019-02-07
    • 2022-06-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-05
    相关资源
    最近更新 更多