How to pull git repository using Rugged ruby gem

296 Views Asked by At

How do I pull changes from remote repo using Rugged ruby gem. Most of question on this topic are outdated as api has changed. I am using a simple repo with nothing complex. I found below code on one of the stackoverflow question but unfortunately its outdated

remote = repo.remotes['origin']
remote.fetch(credentials: credentials)
remote.save

Also remote.fetch gives {:total_objects=>0, :indexed_objects=>0, :received_objects=>0, :local_objects=>0, :total_deltas=>0, :indexed_deltas=>0, :received_bytes=>0} and no changes are pulled

1

There are 1 best solutions below

3
On

The docs have this example:

remote = Rugged::Remote.lookup(@repo, 'origin')
remote.fetch({
  transfer_progress: lambda { |total_objects, indexed_objects, received_objects, local_objects, total_deltas, indexed_deltas, received_bytes|
    # ...
  }
})