Skip to content

Instantly share code, notes, and snippets.

@otac0n
Created March 10, 2026 23:47
Show Gist options
  • Select an option

  • Save otac0n/07acc53454be80091e60aff3c1751167 to your computer and use it in GitHub Desktop.

Select an option

Save otac0n/07acc53454be80091e60aff3c1751167 to your computer and use it in GitHub Desktop.
A PowerShell snipped that uses Git to find identical files that should be updated at the same time.
$hashMap = @{}; git diff-tree -r --find-renames --no-commit-id --diff-filter=M HEAD^ HEAD -- "*.png" | %{
$p = $_ -split '\s+', 6;
$hashMap[$p[2]] = ($hashMap[$p[2]] ?? @()) + $p[3];
};
git ls-tree -r HEAD | ?{ $_ -like "*.png" } | %{
$p = $_ -split '\s+', 4;
($hashMap[$p[2]] ?? @()) | Select-Object -Unique | %{ "{0} {1}" -f $_, $p[3] }
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment