Bindings to libgit2 for interoperating with git repositories. This library is both threadsafe and memory safe and allows both reading and writing git repositories.

84 releases

0.13.12 Oct 14, 2020
0.13.10 Aug 21, 2020
0.13.8 Jul 21, 2020
0.13.0 Mar 13, 2020
0.0.1 Nov 14, 2014

#1 in Development tools

Download history 42344/week @ 2020-07-05 35842/week @ 2020-07-12 35154/week @ 2020-07-19 45628/week @ 2020-07-26 45525/week @ 2020-08-02 38579/week @ 2020-08-09 36838/week @ 2020-08-16 39823/week @ 2020-08-23 40035/week @ 2020-08-30 40235/week @ 2020-09-06 37957/week @ 2020-09-13 38349/week @ 2020-09-20 42692/week @ 2020-09-27 46227/week @ 2020-10-04 47267/week @ 2020-10-11 37514/week @ 2020-10-18

173,354 downloads per month
Used in 425 crates (319 directly)


142K SLoC

C 123K SLoC // 0.1% comments Rust 19K SLoC // 0.0% comments Shell 424 SLoC // 0.1% comments Python 157 SLoC // 0.0% comments



libgit2 bindings for Rust

git2 = "0.13"

Rust version requirements

git2-rs works with stable Rust, and typically works with the most recent prior stable release as well. Check the MSRV job of the CI script to see the oldest version of Rust known to pass tests.

Version of libgit2

Currently this library requires libgit2 1.1.0. The source for libgit2 is included in the libgit2-sys crate so there's no need to pre-install the libgit2 library, the libgit2-sys crate will figure that and/or build that for you.

Building git2-rs

$ git clone https://github.com/rust-lang/git2-rs
$ cd git2-rs
$ cargo build

Automating Testing

Running tests and handling all of the associated edge cases on every commit proves tedious very quickly. To automate tests and handle proper stashing and unstashing of unstaged changes and thus avoid nasty surprises, use the pre-commit hook found here and place it into the .git/hooks/ with the name pre-commit. You may need to add execution permissions with chmod +x.

To skip tests on a simple commit or doc-fixes, use git commit --no-verify.

Building on OSX 10.10+

If the ssh feature is enabled (and it is by default) then this library depends on libssh2 which depends on OpenSSL. To get OpenSSL working follow the openssl crate's instructions.


This project is licensed under either of

at your option.


Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in git2-rs by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


~121K SLoC