blob_id = repo.write("Blob contents", :blob) (1)
index = repo.index
index.read_tree(repo.head.target.tree)
index.add(:path => 'newfile.txt', :oid => blob_id) (2)
sig = {
:email => "bob@example.com",
:name => "Bob User",
:time => Time.now,
}
commit_id = Rugged::Commit.create(repo,
:tree => index.write_tree(repo), (3)
:author => sig,
:committer => sig, (4)
:message => "Add newfile.txt", (5)
:parents => repo.empty? ? [] : [ repo.head.target ].compact, (6)
:update_ref => 'HEAD', (7)
)
commit = repo.lookup(commit_id) (8)