Git: How can I find a commit that most closely matches a directory?

you could write a script, which diffs the given tree against a revision range in your repository.

assume we first fetch the changed tree (without history) into our own repository:

git remote add foreign git://…
git fetch foreign

we then output the diffstat (in short form) for each revision we want to match against:

for REV in $(git rev-list 1.8^..1.9); do
   git diff --shortstat foreign/master $REV;
done

look for the commit with the smallest amount of changes (or use some sorting mechanism)

Leave a Comment