【问题标题】:Push to Git using Rugged使用 Rugged 推送到 Git
【发布时间】:2015-10-26 18:03:42
【问题描述】:

我在脚本中工作以使用脚本推送到 git,所以我选择 Rugged 来执行此操作,当我尝试推送到 repo 时出现问题,它给了我错误,你能帮帮我吗?

require 'rugged'


git_email = 'ettaheri.nizar@gmail.com'
git_name = 'Nizar'
repo_name = '/Users/euphor/Desktop/test/testignore1'


repo = Rugged::Repository.new('/Users/euphor/Desktop/test/testignore1')
puts "1"
index = repo.index
puts "3"

oid = repo.write("This is a blob.", :blob)

index.add(:path => "testignore1", :oid => oid, :mode => 0100644)
puts "4"

options = {}
options[:tree] = index.write_tree(repo)
puts "5"
options[:author] = { :email => git_email, :name => git_name, :time => Time.now }
options[:committer] = { :email => git_email, :name => 'Test Author', :time => Time.now }
puts "6"
options[:message] ||= "Making a commit via Rugged!"
options[:parents] = repo.empty? ? [] : [ repo.head.target ].compact
options[:update_ref] = 'HEAD'
puts "7"
Rugged::Commit.create(repo, options)
puts "8"
**repo.push 'origin'**  # this is my error
puts "Done"

我的错误信息是:

/Library/Ruby/Gems/2.0.0/gems/rugged-0.23.0/lib/rugged/repository.rb:224:in push': Unsupported URL protocol (Rugged::NetworkError) from /Library/Ruby/Gems/2.0.0/gems/rugged-0.23.0/lib/rugged/repository.rb:224:in push' 来自 vips.rb:43:in `'

【问题讨论】:

  • 请在您的存储库中运行git remote show origin 并显示输出。
  • 这是输出:远程来源获取 URL:git@devserver:nizar/testignore1 推送 URL:git@devserver:nizar/testignore1 头分支:主远程分支:主跟踪
  • 这很奇怪。你的操作系统是什么? Ubuntu?
  • 不是 Ubuntu,我用的是 OSX
  • 你的包管理器是什么,Homebrew?

标签: ruby-on-rails ruby git


【解决方案1】:

看起来您没有正确安装 libgit2(Rugged 的​​后端)。最方便的 Mac OS 打包解决方案,如果 Homebrew,您需要它来安装额外的库。

安装 Homebrew

执行此行后按照屏幕上的任何说明进行操作:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

安装 openssh

brew install openssh

重新安装坚固的 gem

gem uninstall rugged
gem install rugged

现在你的 sn-p 应该可以正常运行了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-11-25
    • 1970-01-01
    • 2014-06-12
    • 2012-12-04
    • 2013-05-30
    • 2014-01-06
    • 2015-06-25
    • 1970-01-01
    相关资源
    最近更新 更多