Skip to content

Instantly share code, notes, and snippets.

@bradfitz
Created July 17, 2025 02:16
Show Gist options
  • Save bradfitz/4751c58b07b57ff303cbfec3e39fca93 to your computer and use it in GitHub Desktop.
Save bradfitz/4751c58b07b57ff303cbfec3e39fca93 to your computer and use it in GitHub Desktop.
git tree sorting example
set -eu
mkdir -p /tmp/foo && cd /tmp/foo
git init
mkdir testing
touch testing.md testing/empty-dir
git add testing testing.md
git commit -m 'foo'
git cat-file -p HEAD^{tree}
rm -rf .git testing testing.md
git init
touch testing testing.md
git add testing testing.md
git commit -m 'foo'
git cat-file -p HEAD^{tree}
==>
[main (root-commit) 8b7c54f] foo
2 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 testing.md
create mode 100644 testing/empty-dir
100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 testing.md
040000 tree fa332bbf4255e8027944271b286ef53c785fc2de testing
[main (root-commit) f7d5815] foo
2 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 testing
create mode 100644 testing.md
100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 testing
100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 testing.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment