libgit2 is a portable, pure C implementation of the Git core methods provided as a re-entrant linkable library with a solid API, allowing you to write native speed custom Git applications in any language which supports C bindings.

Getting started

In the current Git project, though a libgit.a file is produced it is not re-entrant (it will call die() on basically any error) and it has no stable or well-designed public API. As there is no good way to link to this effectively, a new library was needed that fulfilled these requirements. Thus libgit2.

libgit2 is...

  • licensed under a very permissive license so you can use it anywhere
  • faster than any other Git library
  • written in portable and standards compilant C
  • completely multi-platform: Windows, Linux, Mac OS X, xBSD and more
  • compiled natively under all platforms (yes, even MSVC on Windows)
  • re-entrant, with sane error handling
  • designed with a solid and consistent API
  • available as bindings for all major scripting languages
  • compiled with minimal external dependencies (currently only zlib)

libgit2 is still in early development, and although it's already quite feature complete, there are no official binary releases available yet. Interested early adopters must compile the library by hand -- which is easy enough to do.

Get the code at GitHub

What it can do

Building the library

libgit2 uses CMake as its buildsystem. In order to build the clar testsuite, it requires Python 2.4 or better. Thanks to CMake it can be built on any platform with the same commands. If you're compiling on Windows with MSVC, make sure you open the VS prompt. Specific instructions for MinGW and using VS solution files are in the wiki. There are more details in the README file.
Start by configuring the build system by running:
$ mkdir build && cd build
$ cmake .. 
Then build the library
$ cmake --build .
You can then test the library with:
$ ctest .
And finally you can install it with (you may need to sudo):
$ cmake --build . --target install
Once that is done, you should be able to link the library to your program with a normal -lgit2.

Language bindings

There are already a number of language bindings in the works, so you can use Git at native speed from your favorite programming language.

Rugged (Ruby bindings)

Rugged (previously known as Ribbit) is the reference binding implementation for libgit2, used to make sure the C API is sane and functional. Rugged is always in sync with the libgit2 master branch. It also has the best name for any Ruby project. Ever.

Get Rugged

objective-git (Objective-C bindings)

Objective-git is another set of reference bindings for libgit2. It's always in sync with the libgit2 master branch, well tested, and tastes like Cocoa.

Get objective-git

pygit2 (Python bindings)

pygit2 are the Python 2.6+ bindings for libgit2 mantained by J. David Ibáñez. They make extensive use of common Python idioms, and also make programming Git applications fun again. They should be (mostly) up to date with the library changes.

Get pygit2

libgit2sharp (.NET bindings)

libgit2sharp is a set of bindings for .NET, maintained by Emeric Fermas. They should be usable from any language that runs on the .NET runtime, including IronPython and IronRuby. How cool is that?

Get libgit2sharp

php-git (PHP bindings)

libgit2 bindings for PHP5, maintained by Shuhei Tanuma.

Get php-git

luagit2 (Lua bindings)

libgit2 bindings for Lua, maintained by Robert G. Jakabosky

Get luagit2

GitForDelphi (Delphi bindings)

libgit2 bindings for Delphi, maintained by Jason Penny

Get GitForDelphi

node-gitteh (Node.js bindings)

libgit2 bindings for Node.js, maintained by samcday. It's like Git, but more asynchronous.

Get node-gitteh

go-git (Go bindings)

libgit2 bindings for Go, maintained by Mike Rosset

Get go-git

libqgit2 (C++ Qt bindings)

libgit2 bindings for C++, tweaked to interact with the Qt library. Maintained by Laszlo Papp.

Get libqgit2

parrot-libgit2 (Parrot Virtual Machine bindings)

parrot-libgit2 are bindings to Parrot VM, which allows all languages running on Parrot access to the libgit2 API.

Get parrot-libgit2

Geef (Erlang bindings)

Geef is an example of an Erlang NIF binding to libgit2. Outdated.

Get Geef

libgit2-glib (GObject bindings)

GObject bindings for libgit2 with support for GObject introspected languages like Python, javascript and vala

Get libgit2-glib

chicken-git (Chicken Scheme bindings)

High- and low-level bindings to libgit2 for Chicken Scheme.

Get chicken-git

Thanks to the folks at Bundler for letting us steal their awesome CSS

Fork me on GitHub