HashTree


Hashtree is a CLI utility to calculate hashes for everything in a directory tree and provide a single composite hash of everything, including subdirectories and their contents.

$ hashtree testing/happy_path
happy_path
┣━big.jpg: 062b949aaf95f87ee123183ddca6deb8
┣━empty.txt: d41d8cd98f00b204e9800998ecf8427e
┣━same contents different name: f11ea1768ecd409899c9402804f7a192
┣━上篇: f11ea1768ecd409899c9402804f7a192
┣━chain
┃ ┣━binary
┃  ┣━katie.jpg: ff1af431750190e13f6b63b1a1a4b17f
┃  ┗━Opal.jpg: 2eda526319e7facd6b941aeec80e5749
┃ ┗━text
┃   ┣━lorem_ipsum.txt: db89bb5ceab87f9c0fcc2ab36c189c2c
┃   ┗━this one has newlines: 1701734cd6b90895d166ce1dda4f4489
┣━empty
┗━humor
  ┗━bee movie.txt: 5c18b58b2e7194a7f78bb55671d43e10

Final hash: c2b54c4674e73d81b84ba643cb607e8d

Use cases

  • determine whether two directories on the same machine are the same without needing to buy or install tools like beyondcompare
  • determine whether two directories on different machines are the same without needing to send them over the network to compare them
  • automated backup deduplication
  • track changes to a file tree through time without needing to store every modification made to every file
  • prove that two different git operations (like rebase and squash) result in identical code

Technical

It's a relatively small, standalone, single-file python program.

It has no dependencies outside of the standard library, but it is my first project built with UV and my first public project that used pytest, as well as linting and type checking tools. To keep all of these tools together I use just.

Downloads

The program's source is available on its github page.

Releases to pip and prebuilt binaries are planned.

Version History

  • 0.1 (released September 7th, 2026): Initial release.

Legal

The code is distributed under the GPL v3 license.

One image included in the tests was downloaded off of wikipedia and was licensed under a CC license. See the github page for more.