Created
April 22, 2021 04:25
-
-
Save danieljurek/280ede135b3085343e2e922c4fd453f5 to your computer and use it in GitHub Desktop.
Windows detect duplicate filenames in git repo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Windows files are case-insensitive by default. It is possible | |
# to have two files with different casing in a git repository | |
# (e.g. foo.txt and FOO.txt). In these situations only one file | |
# will appear in the folder. Changes to this file will confuse | |
# git. Use this script to check for the existence of these | |
# duplicated files. | |
$gitFileHash = @{}; | |
$gitFiles = git ls-files | |
foreach ($file in $gitFiles) { | |
if ($gitFileHash.ContainsKey($file)) { | |
Write-Error "Duplicate file detected: $file" | |
} else { | |
$gitFileHash[$file] = $true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice, how about folders?