Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Working with Git::Raw (libgit2)
use strict;
use warnings;
use Git::Raw;
use IO::File;
use Data::Dumper;
my $dir = '/opt/t3/t/repo';
my $repo = Git::Raw::Repository->init($dir, 0);
print "OK\n";
my $remote =
Git::Raw::Remote->create($repo, 'origin', 'file:///tmp/xxx');
print "OK\n";
#my $fh = IO::File->new($dir . '/xx', 'w');
my $index = $repo->index;
#$index->add ('xx');
my $tree = $index->write_tree;
my $me = Git::Raw::Signature->now('Z', '');
$repo->commit('dada', $me, $me, [], $tree);
print "OK commit\n";
my $branch = Git::Raw::Branch->lookup( $repo, 'master', 1 );
$branch->move('xxxzzz', 1);
print "OK\n";
print $repo->head->target->id;
print "\n";
print "OK push\n";
$branch = Git::Raw::Branch->lookup( $repo, 'xxxzzz', 1 );
my $ref = Git::Raw::Reference->lookup('refs/remotes/origin/gdgdga', $repo);
print "OK upstr\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.