ruby-git无法推动

时间:2016-12-23 10:47:58

标签: ruby git

您好我正在编写aruby脚本来自动执行一些git步骤,我正在使用ruby-git:https://github.com/schacon/ruby-git

我可以克隆,添加和提交我的更改,但在将代码更改推送到远程分支(git push origin)时遇到问题。

任何人都可以帮助我通过ruby-git推送我的更改

这是代码:

def initiate_git_clone
  path = $config['DbDir']
  git_repo_url = $config['GitRepo']
  git_repo_name = $config['GitRepoName']

  Dir.chdir(path)

  puts "\nStarting cloning : #{git_repo_name}"
  g = Git.clone(git_repo_url, git_repo_name, :path => path)
  puts "Clone completed : #{git_repo_name}"

  g.branch('test_branch')
  g.branch('test_branch').checkout

  update_metrics_status ('generating_schema')
end

def commit_and_push
  db_dir = $config['DbDir']
  git_repo_name = $config['GitRepoName']
  working_dir = db_dir + git_repo_name
  g = Git.open(working_dir)
  g.add
  g.commit('test commit')
  g.push(g.remote('origin'))
end

1 个答案:

答案 0 :(得分:0)

考虑push function definition,请尝试简单:

g.push('origin')

(假设您正在处理master分支)

相关问题