130 releases

0.14.0+1.5.0 Jul 28, 2022
0.13.3+1.4.2 Apr 27, 2022
0.13.2+1.4.2 Mar 10, 2022
0.12.26+1.3.0 Dec 1, 2021
0.0.1 Nov 13, 2014

#61 in Development tools

Download history 119895/week @ 2022-06-09 130357/week @ 2022-06-16 110255/week @ 2022-06-23 118572/week @ 2022-06-30 115306/week @ 2022-07-07 123008/week @ 2022-07-14 124408/week @ 2022-07-21 133842/week @ 2022-07-28 133607/week @ 2022-08-04 136201/week @ 2022-08-11 130898/week @ 2022-08-18 128160/week @ 2022-08-25 129809/week @ 2022-09-01 137106/week @ 2022-09-08 144290/week @ 2022-09-15 117254/week @ 2022-09-22

552,746 downloads per month
Used in 828 crates (7 directly)


132K SLoC

C 128K SLoC // 0.1% comments Rust 4K SLoC // 0.0% comments Python 158 SLoC // 0.0% comments Shell 28 SLoC // 0.1% comments



libgit2 bindings for Rust.

git2 = "0.15"

Rust version requirements

git2-rs works with stable Rust, and typically works with the most recent prior stable release as well.

Version of libgit2

Currently this library requires libgit2 1.4. 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 macOS 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.


~79K SLoC