Skip to content

Instantly share code, notes, and snippets.

@jeroen
Created November 26, 2024 11:30
Show Gist options
  • Save jeroen/4e01f13a39107e34ff5db645dcaf7551 to your computer and use it in GitHub Desktop.
Save jeroen/4e01f13a39107e34ff5db645dcaf7551 to your computer and use it in GitHub Desktop.
Example to clone with libgit2
//Compile: gcc test.c $(pkg-config --libs --cflags libgit2)
#include <git2.h>
#include <stdio.h>
int main() {
git_libgit2_init();
git_repository *repo = NULL;
int error = git_clone(&repo, "https://github.com/jeroen/sys", "test", NULL);
if (error < 0) {
const git_error *e = git_error_last();
printf("Error %d/%d: %s\n", error, e->klass, e->message);
return error;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment