#git #git-repository #search #presence #discover #git-dir #upwards

gix-discover

Discover git repositories and check if a directory is a git repository

38 breaking releases

0.51.0 Apr 27, 2026
0.49.0 Mar 22, 2026
0.45.0 Dec 31, 2025
0.43.0 Nov 22, 2025
0.16.2 Mar 30, 2023

#1142 in Filesystem

Download history 666276/week @ 2026-01-23 844227/week @ 2026-01-30 1029434/week @ 2026-02-06 915564/week @ 2026-02-13 579354/week @ 2026-02-20 802658/week @ 2026-02-27 702208/week @ 2026-03-06 677355/week @ 2026-03-13 594319/week @ 2026-03-20 598837/week @ 2026-03-27 710627/week @ 2026-04-03 457591/week @ 2026-04-10 450337/week @ 2026-04-17 518312/week @ 2026-04-24 546785/week @ 2026-05-01 569656/week @ 2026-05-08

2,159,777 downloads per month
Used in 619 crates (13 directly)

MIT/Apache

465KB
9K SLoC

Find git repositories or search them upwards from a starting point, or determine if a directory looks like a git repository.

Note that detection methods are educated guesses using the presence of files, without looking too much into the details.

Examples

let (path, _trust) = gix_discover::upwards(&nested)?;
let (repository_dir, worktree_dir) = path.into_repository_and_work_tree_directories();

assert_eq!(repository_dir, git_dir);
assert_eq!(worktree_dir, Some(dir.path().to_path_buf()));
assert!(gix_discover::is_git(&repository_dir).is_ok());

Dependencies

~10–17MB
~316K SLoC