1

我正在寻找一个可以让我在 Git 存储库上发出一些拉取请求并下载分支文件的 gem。我正在使用这个https://github.com/peter-murach/github#readme但我似乎找不到“获取/拉取”请求。有什么帮助吗?

4

1 回答 1

0

你在寻找git宝石

sudo gem install git

以下是您使用它的方式(摘自自述文件):

   g = Git.init
     Git.init('project')
     Git.init('/home/schacon/proj', 
          { :git_dir => '/opt/git/proj.git', 
             :index_file => '/tmp/index'} )

   g = Git.clone(URI, :name => 'name', :path => '/tmp/checkout')   
   g.config('user.name', 'Scott Chacon')
   g.config('user.email', 'email@email.com')      

   g.add('.')
   g.add([file1, file2])

   g.remove('file.txt')
   g.remove(['file.txt', 'file2.txt'])

   g.commit('message')
   g.commit_all('message')

   g = Git.clone(repo, 'myrepo')
   g.chdir do
    new_file('test-file', 'blahblahblah')
    g.status.changed.each do |file|
     puts file.blob(:index).contents
    end
   end

   g.reset # defaults to HEAD
   g.reset_hard(Git::Commit)

   g.branch('new_branch') # creates new or fetches existing
   g.branch('new_branch').checkout
   g.branch('new_branch').delete
   g.branch('existing_branch').checkout

   g.checkout('new_branch')
   g.checkout(g.branch('new_branch'))

   g.branch(name).merge(branch2)
   g.branch(branch2).merge  # merges HEAD with branch2

   g.branch(name).in_branch(message) { # add files }  # auto-commits
   g.merge('new_branch')
   g.merge('origin/remote_branch')
   g.merge(g.branch('master'))
   g.merge([branch1, branch2])

   r = g.add_remote(name, uri)  # Git::Remote
   r = g.add_remote(name, Git::Base)  # Git::Remote

   g.remotes  # array of Git::Remotes
   g.remote(name).fetch
   g.remote(name).remove
   g.remote(name).merge
   g.remote(name).merge(branch)

   g.fetch
   g.fetch(g.remotes.first)

   g.pull
   g.pull(Git::Repo, Git::Branch) # fetch and a merge

   g.add_tag('tag_name') # returns Git::Tag

   g.repack

   g.push
   g.push(g.remote('name'))
于 2012-09-04T11:59:29.800 回答