116 releases

0.12.18+1.1.0 Jan 21, 2021
0.12.17+1.1.0 Dec 28, 2020
0.12.14+1.1.0 Oct 14, 2020
0.12.9+1.0.1 Jul 21, 2020
0.0.1 Nov 13, 2014

#30 in Development tools

Download history 34661/week @ 2020-12-25 48634/week @ 2021-01-01 49973/week @ 2021-01-08 42226/week @ 2021-01-15 49315/week @ 2021-01-22 49623/week @ 2021-01-29 47884/week @ 2021-02-05 47580/week @ 2021-02-12 54916/week @ 2021-02-19 50345/week @ 2021-02-26 47321/week @ 2021-03-05 46594/week @ 2021-03-12 45541/week @ 2021-03-19 48212/week @ 2021-03-26 44550/week @ 2021-04-02 38822/week @ 2021-04-09

196,728 downloads per month
Used in 528 crates (5 directly)


124K SLoC

C 120K SLoC // 0.1% comments Rust 4K SLoC // 0.0% comments Python 158 SLoC // 0.0% comments Shell 22 SLoC // 0.1% 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.


~66K SLoC