---
title: "git2 0.21.0 Breaking Changes on crates.io | Since.dev"
description: "What each git2 release removed, renamed or changed: 58 breaking changes in 7 versions on crates.io, each with its source."
canonical_url: https://since.dev/packages/crates/git2
last_updated: 2026-12-04
---

# git2 breaking changes

git2 0.21.0 (May 18, 2026) is its newest release with breaking changes, 48 of them. The first: Updated to the 2021 edition in git2 0.21.0. Every breaking API change we have recorded in git2 on crates.io: 58 breaking changes in 7 versions. Below, its 7 versions with breaking changes, newest first, removals and renames first, each with its source.

Updated December 4, 2026

Latest version `0.21.0`, released May 18, 2026. [Source repository](https://github.com/rust-lang/git2-rs)

Packages on crates.io run on Rust. [Rust end of life dates](https://since.dev/calendar/rust.md).

- From [0.15.0](#v-0-15-0) to [0.21.0](#v-0-21-0): 57 breaking changes in 6 versions.

## git2 0.21.0 breaking changes

git2 0.21.0, released May 18, 2026: 48 breaking changes.

- **Behavior changed**  

The crate was updated to the Rust 2021 edition, which may require code adjustments. [github.com](https://github.com/rust-lang/git2-rs/blob/git2-0.21.0/CHANGELOG.md)
- **Behavior changed** `BlameHunk.final_committer`  

BlameHunk::final_committer now returns Option instead of its previous type. [github.com](https://github.com/rust-lang/git2-rs/blob/git2-0.21.0/CHANGELOG.md)
- **Behavior changed** `BlameHunk.final_signature`  

BlameHunk::final_signature, final_committer, orig_signature and orig_committer now return Option to avoid segfaults when signature information is missing. Callers must handle the None case. [github.com](https://github.com/rust-lang/git2-rs/blob/git2-0.21.0/CHANGELOG.md)
- **Behavior changed** `BlameHunk.orig_committer`  

BlameHunk::orig_committer now returns Option instead of its previous type. [github.com](https://github.com/rust-lang/git2-rs/blob/git2-0.21.0/CHANGELOG.md)
- **Behavior changed** `Repository.submodules`  

Many string accessors that returned Option<&str> now return Result<&str, Error> or Result\<Option<&str>, Error>; callers must update how they handle results. [github.com](https://github.com/rust-lang/git2-rs/blob/git2-0.21.0/CHANGELOG.md)
- **Default changed** `ssh`  

The ssh, https and cred Cargo features are no longer on by default (default is now empty). Users relying on credential helpers or transport support must enable them explicitly. [github.com](https://github.com/rust-lang/git2-rs/blob/git2-0.21.0/CHANGELOG.md)
- **Configuration changed** `cred`  

CredentialHelper and the url dependency now require the cred Cargo feature; enabling ssh or https enables cred transitively. [github.com](https://github.com/rust-lang/git2-rs/blob/git2-0.21.0/CHANGELOG.md)
- **Signature changed** `git2::AnnotatedCommit::refname`  

Was fn refname(&self) -> Option<&str>; now fn refname(&self) -> Result<&str, Error>. [crates.io](https://crates.io/crates/git2/0.21.0)
- **Signature changed** `git2::BlameHunk::final_signature`  

Was fn final_signature(&self) -> Signature<'\_>; now fn final_signature(&self) -> Option\<Signature<'\_>>. [crates.io](https://crates.io/crates/git2/0.21.0)
- **Signature changed** `git2::BlameHunk::orig_signature`  

Was fn orig_signature(&self) -> Signature<'\_>; now fn orig_signature(&self) -> Option\<Signature<'\_>>. [crates.io](https://crates.io/crates/git2/0.21.0)
- **Signature changed** `git2::Buf::as_str`  

Was fn as_str(&self) -> Option<&str>; now fn as_str(&self) -> Result<&str, Error>. [crates.io](https://crates.io/crates/git2/0.21.0)
- **Signature changed** `git2::Commit::body`  

Was fn body(&self) -> Option<&str>; now fn body(&self) -> Result\<Option<&str>, Error>. [crates.io](https://crates.io/crates/git2/0.21.0)
- **Signature changed** `git2::Commit::message`  

Was fn message(&self) -> Option<&str>; now fn message(&self) -> Result<&str, Error>. [crates.io](https://crates.io/crates/git2/0.21.0)
- **Signature changed** `git2::Commit::message_encoding`  

Was fn message_encoding(&self) -> Option<&str>; now fn message_encoding(&self) -> Result\<Option<&str>, Error>. [crates.io](https://crates.io/crates/git2/0.21.0)
- **Signature changed** `git2::Commit::message_raw`  

Was fn message_raw(&self) -> Option<&str>; now fn message_raw(&self) -> Result<&str, Error>. [crates.io](https://crates.io/crates/git2/0.21.0)
- **Signature changed** `git2::Commit::raw_header`  

Was fn raw_header(&self) -> Option<&str>; now fn raw_header(&self) -> Result<&str, Error>. [crates.io](https://crates.io/crates/git2/0.21.0)
- **Signature changed** `git2::Commit::summary`  

Was fn summary(&self) -> Option<&str>; now fn summary(&self) -> Result\<Option<&str>, Error>. [crates.io](https://crates.io/crates/git2/0.21.0)
- **Signature changed** `git2::ConfigEntry::name`  

Was fn name(&self) -> Option<&str>; now fn name(&self) -> Result<&str, Error>. [crates.io](https://crates.io/crates/git2/0.21.0)
- **Signature changed** `git2::ConfigEntry::value`  

Was fn value(&self) -> Option<&str>; now fn value(&self) -> Result<&str, Error>. [crates.io](https://crates.io/crates/git2/0.21.0)
- **Signature changed** `git2::MergeFileResult::path`  

Was fn path(&self) -> Option<&str>; now fn path(&self) -> Result\<Option<&str>, Error>. [crates.io](https://crates.io/crates/git2/0.21.0)
- **Signature changed** `git2::Note::message`  

Was fn message(&self) -> Option<&str>; now fn message(&self) -> Result<&str, Error>. [crates.io](https://crates.io/crates/git2/0.21.0)
- **Signature changed** `git2::PackBuilder::name`  

Was fn name(&self) -> Option<&str>; now fn name(&self) -> Result\<Option<&str>, Error>. [crates.io](https://crates.io/crates/git2/0.21.0)
- **Signature changed** `git2::PushUpdate::dst_refname`  

Was fn dst_refname(&self) -> Option<&str>; now fn dst_refname(&self) -> Result<&str, Error>. [crates.io](https://crates.io/crates/git2/0.21.0)
- **Signature changed** `git2::PushUpdate::src_refname`  

Was fn src_refname(&self) -> Option<&str>; now fn src_refname(&self) -> Result<&str, Error>. [crates.io](https://crates.io/crates/git2/0.21.0)
- **Signature changed** `git2::Rebase::orig_head_name`  

Was fn orig_head_name(&self) -> Option<&str>; now fn orig_head_name(&self) -> Result\<Option<&str>, Error>. [crates.io](https://crates.io/crates/git2/0.21.0)
- **Signature changed** `git2::RebaseOperation::exec`  

Was fn exec(&self) -> Option<&str>; now fn exec(&self) -> Result\<Option<&str>, Error>. [crates.io](https://crates.io/crates/git2/0.21.0)
- **Signature changed** `git2::Reference::name`  

Was fn name(&self) -> Option<&str>; now fn name(&self) -> Result<&str, Error>. [crates.io](https://crates.io/crates/git2/0.21.0)
- **Signature changed** `git2::Reference::shorthand`  

Was fn shorthand(&self) -> Option<&str>; now fn shorthand(&self) -> Result<&str, Error>. [crates.io](https://crates.io/crates/git2/0.21.0)
- **Signature changed** `git2::Reference::symbolic_target`  

Was fn symbolic_target(&self) -> Option<&str>; now fn symbolic_target(&self) -> Result\<Option<&str>, Error>. [crates.io](https://crates.io/crates/git2/0.21.0)
- **Signature changed** `git2::ReflogEntry::message`  

Was fn message(&self) -> Option<&str>; now fn message(&self) -> Result\<Option<&str>, Error>. [crates.io](https://crates.io/crates/git2/0.21.0)
- **Signature changed** `git2::Refspec::dst`  

Was fn dst(&self) -> Option<&str>; now fn dst(&self) -> Result<&str, Error>. [crates.io](https://crates.io/crates/git2/0.21.0)
- **Signature changed** `git2::Refspec::src`  

Was fn src(&self) -> Option<&str>; now fn src(&self) -> Result<&str, Error>. [crates.io](https://crates.io/crates/git2/0.21.0)
- **Signature changed** `git2::Refspec::str`  

Was fn str(&self) -> Option<&str>; now fn str(&self) -> Result<&str, Error>. [crates.io](https://crates.io/crates/git2/0.21.0)
- **Signature changed** `git2::Remote::name`  

Was fn name(&self) -> Option<&str>; now fn name(&self) -> Result\<Option<&str>, Error>. [crates.io](https://crates.io/crates/git2/0.21.0)
- **Signature changed** `git2::Remote::pushurl`  

Was fn pushurl(&self) -> Option<&str>; now fn pushurl(&self) -> Result\<Option<&str>, Error>. [crates.io](https://crates.io/crates/git2/0.21.0)
- **Signature changed** `git2::Remote::url`  

Was fn url(&self) -> Option<&str>; now fn url(&self) -> Result<&str, Error>. [crates.io](https://crates.io/crates/git2/0.21.0)
- **Signature changed** `git2::Repository::namespace`  

Was fn namespace(&self) -> Option<&str>; now fn namespace(&self) -> Result\<Option<&str>, Error>. [crates.io](https://crates.io/crates/git2/0.21.0)
- **Signature changed** `git2::Signature::email`  

Was fn email(&self) -> Option<&str>; now fn email(&self) -> Result<&str, Error>. [crates.io](https://crates.io/crates/git2/0.21.0)
- **Signature changed** `git2::Signature::name`  

Was fn name(&self) -> Option<&str>; now fn name(&self) -> Result<&str, Error>. [crates.io](https://crates.io/crates/git2/0.21.0)
- **Signature changed** `git2::StatusEntry::path`  

Was fn path(&self) -> Option<&str>; now fn path(&self) -> Result<&str, Error>. [crates.io](https://crates.io/crates/git2/0.21.0)
- **Signature changed** `git2::string_array::StringArray::get`  

Was fn get(&self, i: usize) -> Option<&str>; now fn get(&self, i: usize) -> Result\<Option<&str>, Error>. [crates.io](https://crates.io/crates/git2/0.21.0)
- **Signature changed** `git2::Submodule::branch`  

Was fn branch(&self) -> Option<&str>; now fn branch(&self) -> Result\<Option<&str>, Error>. [crates.io](https://crates.io/crates/git2/0.21.0)
- **Signature changed** `git2::Submodule::name`  

Was fn name(&self) -> Option<&str>; now fn name(&self) -> Result<&str, Error>. [crates.io](https://crates.io/crates/git2/0.21.0)
- **Signature changed** `git2::Submodule::url`  

Was fn url(&self) -> Option<&str>; now fn url(&self) -> Result\<Option<&str>, Error>. [crates.io](https://crates.io/crates/git2/0.21.0)
- **Signature changed** `git2::Tag::message`  

Was fn message(&self) -> Option<&str>; now fn message(&self) -> Result\<Option<&str>, Error>. [crates.io](https://crates.io/crates/git2/0.21.0)
- **Signature changed** `git2::Tag::name`  

Was fn name(&self) -> Option<&str>; now fn name(&self) -> Result<&str, Error>. [crates.io](https://crates.io/crates/git2/0.21.0)
- **Signature changed** `git2::TreeEntry::name`  

Was fn name(&self) -> Option<&str>; now fn name(&self) -> Result<&str, Error>. [crates.io](https://crates.io/crates/git2/0.21.0)
- **Signature changed** `git2::Worktree::name`  

Was fn name(&self) -> Option<&str>; now fn name(&self) -> Result\<Option<&str>, Error>. [crates.io](https://crates.io/crates/git2/0.21.0)

## git2 0.20.0 breaking changes

git2 0.20.0, released January 5, 2025: 2 breaking changes.

- **Signature changed** `git2::Error::last_error`  

Was fn last_error(code: c_int) -> Option\<Error>; now fn last_error(code: c_int) -> Error. [crates.io](https://crates.io/crates/git2/0.20.0)
- **Signature changed** `git2::trace_set`  

Was fn trace_set(level: TraceLevel, cb: TracingCb) -> bool; now fn trace_set(level: TraceLevel, cb: TracingCb) -> Result<(), Error>. [crates.io](https://crates.io/crates/git2/0.20.0)

## git2 0.19.0 breaking changes

git2 0.19.0, released June 14, 2024: 2 breaking changes.

- **Behavior changed**  

The release bundles libgit2 1.8.1 and is marked as a breaking change by the maintainers. Check code that depends on libgit2 behavior after upgrading. [github.com](https://github.com/rust-lang/git2-rs/blob/git2-0.19.0/CHANGELOG.md)
- **Signature changed** `git2::Remote::update_tips`  

Was fn update_tips(&mut self, callbacks: Option<&mut RemoteCallbacks<'\_>>, update_fetchhead: bool, download_tags: AutotagOption, msg: Option<&str>) -> Result<(), Error>; now fn update_tips(&mut self, callbacks: Option<&mut... [crates.io](https://crates.io/crates/git2/0.19.0)

## git2 0.18.0 breaking changes

git2 0.18.0, released August 28, 2023: 2 breaking changes.

- **Behavior changed**  

Types generated by bitflags may differ slightly; code relying on bitflags 1.x generated types may need updates. [github.com](https://github.com/rust-lang/git2-rs/blob/git2-0.18.0/CHANGELOG.md)
- **Signature changed** `git2::Revwalk::with_hide_callback`  

The callback must now be passed as a mutable reference to enforce type safety; update call sites that pass a shared reference. [crates.io](https://crates.io/crates/git2/0.18.0)

## git2 0.17.0 breaking changes

git2 0.17.0, released April 2, 2023: 2 breaking changes.

- **Behavior changed** `RemoteCallbacks.credentials`  

Errors returned from the credentials callback now carry the correct libgit2 error class, which may change how callers match on errors. [github.com](https://github.com/rust-lang/git2-rs/blob/0.17.0/CHANGELOG.md)
- **Signature changed** `DiffOptions.flag`  

The flag method's parameter type changed to git_diff_option_t, so callers passing the old type must update. [github.com](https://github.com/rust-lang/git2-rs/blob/0.17.0/CHANGELOG.md)

## git2 0.16.0 breaking changes

git2 0.16.0, released January 10, 2023: 1 breaking change.

- **Signature changed** `git2::RemoteCallbacks::certificate_check`  

Was fn certificate_check\<F>(&mut self, cb: F) -> &mut RemoteCallbacks<'a> where F: FnMut(&Cert<'\_>, &str) -> bool + 'a,; now fn certificate_check\<F>(&mut self, cb: F) -> &mut RemoteCallbacks<'a> where F: FnMut(&Cert<'\_>, &str) ->... [crates.io](https://crates.io/crates/git2/0.16.0)

## Older versions

1 older version.

### git2 0.15.0 breaking changes

git2 0.15.0, released July 28, 2022: 1 breaking change.

- **Removed** `git2::Diff::format_email`  

git2::Diff::format_email was removed in git2 0.15.0 [crates.io](https://crates.io/crates/git2/0.15.0)

## Check your code

These are the changes. To see which of them reach your code, [scan a public repository](https://since.dev/scan.md), or have your coding agent call `check_code` with your manifest or lockfile over [MCP](https://since.dev/docs.md#mcp). [The API](https://since.dev/docs.md#api) reads every change in every version. A fix pull request opens for the changes that reach a connected repository. Nothing merges or deploys.

## Put your code on continuous maintenance.

Scan a public repository now, or give your agent one line.

[Scan a repository](https://since.dev/scan.md). Any public GitHub repository. No sign-in.

### Tell your agent what changed since it was trained.

`claude mcp add --transport http since https://api.since.dev/mcp`

[Get an API key](https://app.since.dev/login?mode=signup)

Codex, Cursor and any MCP client use https://api.since.dev/mcp.

---

Every page on this site as Markdown: https://since.dev/sitemap.md. For agents: https://since.dev/llms.txt.
