使用Rugged推送到Git
我在脚本中使用脚本来推送git,所以我选择Rugged来做那个,当我尝试推送回购时我的问题,它给了我错误,你能帮我吗?
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’from vips.rb:43:in`’
看起来你没有正确安装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
现在你的代码段运行正常。
- Heroku在git push上部署“预编译资产失败”
- 在Gemfile中使用git repo时的Gem :: LoadError
- 调试Heroku应用程序时如何避免大量提交
- $ git push heroku master – 没有错误消息,但更改未显示在Web应用程序上
- 使用capistrano部署远程git repo但没有在生产服务器上运行git
- 无法在Windows上运行捆绑软件更新
- 当我运行git push heroku master命令时,Heroku推送失败
- 如何保持git repo的公共和私有版本同步?
- 预编译资产失败ExecJS :: ProgramError:意外的标记:operator(=)(行:10770,col:0,pos:300859)