git - Heroku pull 私有(private) github 存储库

标签 git heroku github

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

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 token 。

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

最佳答案

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

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

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

使用:

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

关于git - Heroku pull 私有(private) github 存储库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13137996/

相关文章:

git - 在 BitBucket SourceTree 中 checkout 、获取和 pull

git - 如何在 git 中配置多个 CA 证书?

node.js - Heroku 上的套接字 io

ruby - 如何在不先保存文本文件的情况下在 Ruby 中使用 FTP

git .BACKUP .BASE .LOCAL .REMOTE 文件

ruby-on-rails - 如何清除 Rails Action 缓存? (Rails.cache.clear 不工作)

github - 如何使用 GitHub 存储库中的 used by 按钮

Git fetch 浅克隆没有获取匹配的提交

android - 在 Android Studio 中使用 github 库

git - 我可以在不先从原点调用 fetch 的情况下 rebase 吗?