#git #git2

sys libgit2-sys

Native bindings to the libgit2 library

137 releases

0.16.1+1.7.1 Aug 28, 2023
0.15.2+1.6.4 May 28, 2023
0.14.2+1.5.1 Jan 20, 2023
0.14.0+1.5.0 Jul 28, 2022
0.0.1 Nov 13, 2014

#39 in Development tools

Download history 202637/week @ 2023-08-12 216694/week @ 2023-08-19 206772/week @ 2023-08-26 186090/week @ 2023-09-02 198653/week @ 2023-09-09 198762/week @ 2023-09-16 181044/week @ 2023-09-23 198331/week @ 2023-09-30 224590/week @ 2023-10-07 225801/week @ 2023-10-14 198303/week @ 2023-10-21 209551/week @ 2023-10-28 208133/week @ 2023-11-04 232826/week @ 2023-11-11 199585/week @ 2023-11-18 166927/week @ 2023-11-25

838,417 downloads per month
Used in 1,254 crates (8 directly)


135K SLoC

C 131K 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.17.2"

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.6.4 (or newer patch versions). 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.


~80K SLoC