git2
Bindings to libgit2 for interoperating with git repositories. This library is both threadsafe and memory safe and allows both reading and writing git repositories.
0.21.0
109M downloads/mo
#760 most downloaded on crates.io
rust-lang/git2-rs
What this package is like to depend on
Last release 3 months ago
18 May 2026
Ships fairly regularly
a new release about every 3 months
Rarely documented
notes for 22 of 119 stable releases
6 versions withdrawn
withdrawn after publishing
12 years old
125 releases · first in 2014
3 releases in the last 12 months
see the full history below
Release timeline
125 releases · Nov 2014 to May 2026Releases
latest 60 of 125-
0.21.018 May 2026Release notes
Open source →Added
- Added experimental SHA256 repository support behind the new
unstable-sha256Cargo feature, along with*_extAPI variants that accept anObjectFormat. #1206 - Added
opts::set_cache_max_size()andopts::get_cached_memory(). #1188 - Added
Repository::object_format()and a newObjectFormatenum. #1204 - Added
Repository::set_config(). #1208 - Added
merge_file()along withMergeFileInput. #1210 - Added
Repository::refdb_compress()for packing loose refs. #1221 - Added public
Refdbtype, along withRepository::refdb()andRepository::set_refdb().Repository::refdb_compress()now delegates toRefdb::compress(). #1228 - Added
Revspec::into_objects(). #1230 - Added
BlameHunk::final_committer(),BlameHunk::orig_committer(),BlameHunk::summary(), andBlameHunk::summary_bytes(). #1231 - Implemented
CloneforReference. #1233 - Added
Repository::author_from_env()andRepository::committer_from_env(). #1237 - Added
impl From<Utf8Error> for Error. #1239
Changed
- ❗ The
ssh,https, andcredCargo features are no longer enabled by default. Previouslydefault = ["ssh", "https"]; nowdefault = []. Enable them explicitly if you rely on credential helpers or transport support. #1168 - ❗
CredentialHelperand theurldependency are now gated behind the newcredCargo feature. Enablingsshorhttpstransitively enablescred. #1168 - ❗ Updated to the 2021 edition. #1173
- ❗ Many string accessors that previously returned
Option<&str>now returnResult<&str, Error>orResult<Option<&str>, Error>, so callers can distinguish a missing value from a non-UTF-8 one. #1241 - ❗
BlameHunk::final_signature,BlameHunk::final_committer,BlameHunk::orig_signature, andBlameHunk::orig_committernow returnOptionto avoid segfaults when signature information is missing. #1254 - Bumped requirement to libgit2-sys 0.18.4, which updates libgit2 to 1.9.3. #1242
Fixed
- Fixed
MergeOptions::skip_reuc()to use the correctGIT_MERGE_SKIP_REUCflag. #1194 Repository::submodules()now returns anErrorwhen the underlyinggit_submodule_lookup()call to libgit2 fails, rather than panicking with a failed assertion. #1220Reference::is_valid_name()now propagates errors fromCStringconversion instead of panicking. #1229- Fixed
Remote::list()to return an empty list instead of erroring when the remote advertises no refs. #1250 ReferenceNamesnow returns anErrfor non-UTF-8 branch names instead of panicking. #1239
Documentation
- Added note regarding potentially confusing behavior of
git_checkout_head. #1149 - Added comments describing the
IndexAddOptionflags. #1163 - Updated README note about the
sshfeature. #1187 - Improved function docs for
Repository::tag_foreach(). #1190 - Fixed doc comment typo in
StatusOptions. #1199 - Fixed missing period in module documentation. #1219
- Small wording fix in
Signature::from_raw_const()docs. #1222 - Replaced discussion of missing gist in README. #1223
- Documented the bitflag methods for checking flags. #1224
- Clarified
CheckoutBuilder::update_index()documentation. #1232 - Added more missing documentation. #1235
- Fixed typo in
Repository::stash_save_ext()docs. #1245 - Added example showing retrieval of the latest commit for a file. #1243
- Replaced comma with period in
CheckoutBuilder::refresh()docs. #1252
Internals
- Dropped
civet/conduitfrom dev-dependencies. #1170 - Updated dependencies. #1171
- Fixed lockfile verification in CI. #1177
- Updated CI and documentation to cover feature combinations. #1182
- Listed all examples that may need HTTP and SSH. #1196
- Allowed publishing from any ref in the publish workflow. #1198
- Bumped
timefrom 0.3.41 to 0.3.47. #1215 - Added end-to-end test for branch name on initialization. #1244
- Added end-to-end test for stash count. #1246
- Added end-to-end tests demonstrating use of
Repository::statuses(). #1251 - Internal refactors preparing for experimental SHA256 OID support. #1201 #1205
- Added experimental SHA256 repository support behind the new
-
0.20.402 Feb 2026Release notes
Open source → -
0.20.306 Dec 2025Release notes
Open source →Changed
- Bumped requirement to libgit2-sys 0.18.3, which updates libgit2 from 1.9.0 to 1.9.2. #1197
-
0.20.205 May 2025 -
0.20.117 Mar 2025Release notes
Open source →Added
- Added
Repository::branch_upstream_merge()#1131 - Added
Index::conflict_get()#1134 - Added
Index::conflict_remove()#1133 - Added
opts::set_cache_object_limit()#1118 - Added
Repo::merge_file_from_index()and associatedMergeFileOptionsandMergeFileResult. #1062
Changed
- The
urldependency minimum raised to 2.5.4 #1128 - Changed the tracing callback to abort the process if the callback panics instead of randomly detecting the panic in some other function. #1121
- Credential helper config (loaded with
CredentialHelper::config) now checks for helpers that start with something that looks like an absolute path, rather than checking for a/or\anywhere in the helper string (which resolves an issue if the helper had arguments with/or\). #1137
Fixed
- Added
-
0.20.005 Jan 2025Release notes
Open source →Added
Debugis now implemented fortransport::Service#1074- Added
Repository::commondir#1079 - Added
Repository::merge_base_octopus#1088 - Restored impls for
PartialOrd,Ord, andHashfor bitflags types that were inadvertently removed in a prior release. #1096 - Added
CheckoutBuilder::disable_pathspec_match#1107 - Added
PackBuilder::write#1110
Changed
- ❗ Updated to libgit2 1.9.0 #1111
- ❗ Removed the
ssh_key_from_memoryCargo feature, it was unused. #1087 - ❗ Errors from
Tree::walkare now correctly reported to the caller. #1098 - ❗ The
trace_setcallback now takes a&[u8]instead of a&str. #1071 - ❗
Error::last_errornow returnsErrorinstead ofOption<Error>. #1072
Fixed
-
0.19.014 Jun 2024Release notes
Open source →Added
- Added
optsfunctions to control server timeouts (get_server_connect_timeout_in_milliseconds,set_server_connect_timeout_in_milliseconds,get_server_timeout_in_milliseconds,set_server_timeout_in_milliseconds), and addErrorCode::Timeout. #1052
Changed
Fixed
- Fixed some callbacks to relay the error from the callback to libgit2. #1043
- Added
-
0.18.319 Mar 2024Release notes
Open source →Added
- Added
opts::functions to get / set libgit2 mwindow options #1035
Changed
- Updated examples to use clap instead of structopt #1007
- Added
-
0.18.207 Feb 2024Release notes
Open source →Added
- Added
opts::set_ssl_cert_fileandopts::set_ssl_cert_dirfor setting Certificate Authority file locations. #997 - Added
TreeIter::nthwhich makes jumping ahead in the iterator more efficient. #1004 - Added
Repository::find_commit_by_prefixto find a commit by a shortened hash. #1011 - Added
Repository::find_tag_by_prefixto find a tag by a shortened hash. #1015 - Added
Repository::find_object_by_prefixto find an object by a shortened hash. #1014
Changed
- ❗ Updated to libgit2 1.7.2. This fixes CVE-2024-24575 and CVE-2024-24577. #1017
- Added
-
0.18.120 Sep 2023Release notes
Open source →Added
- Added
FetchOptions::depthto set the depth of a fetch or clone, adding support for shallow clones. #979
Fixed
- Added
-
0.18.028 Aug 2023Release notes
Open source →Added
- Added
Blame::blame_bufferfor getting blame data for a file that has been modified in memory. #981
Changed
- Updated to libgit2 1.7.0. #968
- Updated to libgit2 1.7.1. #982
- Switched from bitflags 1.x to 2.1. This brings some small changes to types generated by bitflags. #973
- Changed
Revwalk::with_hide_callbackto take a mutable reference to its callback to enforce type safety. #970 - Implemented
FusedIteratorfor many iterators that can support it. #955
Fixed
- Fixed builds with cargo's
-Zminimal-versions. #960
- Added
-
0.17.228 May 2023Release notes
Open source →Added
- Added support for stashing with options (which can support partial stashing). #930
-
0.17.116 Apr 2023 -
0.17.002 Apr 2023Release notes
Open source →Added
- Added
IntoIteratorimplementation forStatuses. #880 - Added
Reference::symbolic_set_target#893 - Added
Copy,Clone,Debug,PartialEq, andEqimplementations forAutotagOptionandFetchPrune. #889 - Added
EqandPartialEqimplementations forSignature. #890 - Added
Repository::discover_path. #883 - Added
Submodule::repo_init. #914 - Added
Tag::is_valid_name. #882 - Added
Repository::set_head_bytes. #931 - Added the
Indexertype which is a low-level API for storing and indexing pack files. #911 - Added
Index::find_prefix. #903 - Added support for the deprecated group-writeable blob mode. This adds a new variant to
FileMode. #887 - Added
PushCallbacks::push_negotiationcallback and the correspondingPushUpdatetype for getting receiving information about the updates to perform. #926
Changed
- Updated to libgit2 1.6.3. This brings in many changes, including better SSH host key support on Windows and better SSH host key algorithm negotiation. 1.6.3 is now the minimum supported version. #935
- Updated libssh2-sys from 0.2 to 0.3. This brings in numerous changes, including SHA2 algorithm support with RSA. #919
- Changed
RemoteCallbacks::credentialscallback error handler to correctly set the libgit2 error class. #918 DiffOptions::flagnow takes agit_diff_option_ttype. #935
- Added
-
0.16.120 Jan 2023 -
0.16.010 Jan 2023Release notes
Open source →Changed
- Added ability to get the SSH host key and its type.
This includes an API breaking change to the
certificate_checkcallback. #909 - Updated to libgit2-sys 0.14.1+1.5.0
- Added ability to get the SSH host key and its type.
This includes an API breaking change to the
-
0.15.028 Jul 2022Release notes
Open source →Added
- Added
Repository::tag_annotation_createbindinggit_tag_annotation_create. #845 - Added the
Emailtype which represents a patch in mbox format for sending via email. Added theEmailCreateOptionsstruct to control formatting of the email. DeprecatesDiff::format_email, useEmail::from_diffinstead. #847 - Added
ErrorCode::Ownerto map to the newGIT_EOWNERerrors. #839 - Added
opts::set_verify_owner_validationto set whether or not ownership validation is performed. #839
Changed
- Updated to libgit2-sys 0.14.0+1.5.0
- Removed the
Iteratorimplementation forConfigEntriesdue to the unsound usage of the API which allowed values to be used after free. AddedConfigEntries::nextandConfigEntries::for_eachfor iterating over all entries in a safe manor. #854
- Added
-
0.14.410 May 2022Release notes
Open source →Added
- Added
Commit::bodyandCommit::body_bytesfor retrieving the commit message body. #835 - Added
Tree::get_name_bytesto handle non-UTF-8 entry names. #841
Changed
- Updated to libgit2-sys 0.13.4+1.4.2
- Added
-
0.14.327 Apr 2022Release notes
Open source →Changed
- Updated to libgit2-sys 0.13.3+1.4.2
Fixed
- Fixed the lifetime of
Remote::create_detached. #825
-
0.14.210 Mar 2022Release notes
Open source →Added
- Added
Odb::exists_extto checks if an object database has an object, with extended flags. #818
Changed
- Updated to libgit2-sys 0.13.2+1.4.2
- Added
-
0.14.128 Feb 2022 -
0.14.024 Feb 2022Release notes
Open source →Added
- Added
opts::get_extensionsandopts::set_extensionsto support git extensions. #791 - Added
PackBuilder::nameandPackBuilder::name_bytes. #806- Deprecated
PackBuilder::hash, usePackBuilder::nameinstead.
- Deprecated
- Added
FetchOptions::follow_redirectsandPushOptions::follow_redirects. #806 - Added
StatusOptions::rename_threshold. #806
Changed
- Updated to libgit2-sys 0.13.0+1.4.1 #806 #811
- Added
-
0.13.2501 Dec 2021Nothing published for this version
-
0.13.2416 Nov 2021Nothing published for this version
-
0.13.2301 Oct 2021Nothing published for this version
-
0.13.2208 Sep 2021Nothing published for this version
-
0.13.2112 Aug 2021Nothing published for this version
-
0.13.2024 May 2021Nothing published for this version
-
0.13.1911 May 2021Nothing published for this version
-
0.13.1819 Apr 2021Nothing published for this version
-
0.13.1724 Jan 2021Nothing published for this version
-
0.13.1621 Jan 2021Nothing published for this version
-
0.13.1528 Dec 2020Nothing published for this version
-
0.13.1422 Dec 2020Nothing published for this version
-
0.13.1318 Dec 2020Nothing published for this version
-
0.13.1214 Oct 2020Nothing published for this version
-
0.13.1108 Sep 2020Nothing published for this version
-
0.13.1021 Aug 2020Nothing published for this version
-
0.13.919 Aug 2020Nothing published for this version
-
0.13.821 Jul 2020Nothing published for this version
-
0.13.721 Jul 2020 withdrawnNothing published for this version
-
0.13.619 May 2020Nothing published for this version
-
0.13.524 Apr 2020Nothing published for this version
-
0.13.423 Apr 2020Nothing published for this version
-
0.13.322 Apr 2020Nothing published for this version
-
0.13.210 Apr 2020Nothing published for this version
-
0.13.101 Apr 2020Nothing published for this version
-
0.13.013 Mar 2020Nothing published for this version
-
0.12.026 Feb 2020Nothing published for this version
-
0.11.012 Dec 2019Nothing published for this version
-
0.10.220 Nov 2019Nothing published for this version
-
0.10.109 Sep 2019Nothing published for this version
-
0.10.020 Aug 2019Nothing published for this version
-
0.9.224 Jul 2019Nothing published for this version
-
0.9.107 Jun 2019Nothing published for this version
-
0.9.004 Jun 2019Nothing published for this version
-
0.8.013 Dec 2018Nothing published for this version
-
0.7.502 Aug 2018Nothing published for this version
-
0.7.430 Jul 2018Nothing published for this version
-
0.7.322 Jul 2018Nothing published for this version