我正在寻找一些代码示例,无论是坚固还是砂砾,都展示了如何做git push.
我有耙任务deploy:staging和deploy:production我用来部署我的应用程序.
我正在部署到heroku,所以这些任务基本上执行以下操作:
git describe --abbrev=0)git push staging v1.00)heroku config:add APP_VERSION=v1.00)(还有一些检查,以确保我没有忘记在推之前创建一个新的标签等)
最初我使用来自Rakefile的系统调用来获取这些CLI命令; 然后我开始使用git和heroku-api宝石.
然而git gem似乎被抛弃了(过去一年没有提交); 似乎Grit和坚固耐用现在是与Git合作的标准宝石.
不幸的是,由于缺乏文档,我无法弄清楚如何使用这些库中的任何一个进行git推送.
(在以下示例中,假设我正在推送的远程/分支是origin/master,并且已在本地repo中设置为远程)
从坚固开始:
$ irb
2.0.0-p0 :001 > require 'rugged'
=> true
2.0.0-p0 :002 > repo = Rugged::Repository.new('/path/to/repo')
=> #<Rugged::Repository:0x007fe8b48821c0 @encoding=#<Encoding:UTF-8>>
2.0.0-p0 :003 > remote = Rugged::Remote.lookup(repo, 'origin')
NoMethodError: undefined method `lookup' for Rugged::Remote:Class
Run Code Online (Sandbox Code Playgroud)
现在为砂砾:
$ irb
2.0.0-p0 :001 > require 'grit'
=> true
2.0.0-p0 :002 > repo = Grit::Repo.new('/path/to/repo')
=> #<Grit::Repo "/path/to/repo/.git">
2.0.0-p0 :004 > remote = repo.remotes.last
=> #<Grit::Remote "origin/master">
2.0.0-p0 :005 > repo.git.push(remote)
NoMethodError: undefined method `delete' for #<Grit::Remote "origin/master">
Run Code Online (Sandbox Code Playgroud)
任何帮助将不胜感激.
好吧,我想我已经明白了,但现在它要求我提供 gitHub 凭据,但我无法输入我的凭据,因为我收到“超时”错误。
这就是我所做的:
repo.git.remote({},'add','RemoteRepoName',' https://github.com/ /.git')
Pusher = repo.git.push({:process_info => true, :progress => true}, 'RemoteRepoName', 'master')