#gitignore #glob #testing #file #matching #excluded

bin+lib gitignore

Implementation of .gitignore file parsing and glob testing in Rust

8 stable releases

Uses old Rust 2015

1.0.7 Aug 17, 2020
1.0.6 Feb 13, 2017
1.0.5 Oct 5, 2016
1.0.4 Jan 12, 2016
1.0.1 Jun 20, 2015
Download history 2200/week @ 2021-08-11 2495/week @ 2021-08-18 3024/week @ 2021-08-25 2970/week @ 2021-09-01 4266/week @ 2021-09-08 4612/week @ 2021-09-15 4189/week @ 2021-09-22 3984/week @ 2021-09-29 4330/week @ 2021-10-06 4843/week @ 2021-10-13 4056/week @ 2021-10-20 3409/week @ 2021-10-27 3223/week @ 2021-11-03 3359/week @ 2021-11-10 3826/week @ 2021-11-17 2738/week @ 2021-11-24

13,684 downloads per month
Used in 12 crates (11 directly)


464 lines

gitignore.rs Build Status Crates.io Version Of gitignore

This is an implementation of .gitignore parsing and matching in Rust. Use this library if you want to check whether a given path would be excluded by a .gitignore file.

It currently builds on both nighly and stable versions of Rust.


The crate is called gitignore and you can it is available via crates.io:

gitignore = "x.y.z"

You can also use the Git version directory simply by depending on it via Cargo:

git = "https://github.com/nathankleyn/gitignore.rs.git"

There are some useful bundled binaries which you can view to see how you might apply this library. The Rust docs are available to view as well.


A simple example is as follows:

// Create a file
let file = gitignore::File::new(&path_to_gitignore).unwrap();

// This returns a bool as to whether the file matches a rule in the .gitignore file.


Licensed under either of

at your option.


Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.