Maxim Suslov
Maxim Suslov

Reputation: 5475

On Windows git can't handle files with the same name but in different case properly

I use git on windows. In my project I changed case of filename. After that checkout of previous commits failed (commands are in Git Bash):

mkdir repofolder
cd repofolder
git init # create empty repo
git config core.ignorecase false # turn on case-dependent filenames

# create 'readme.txt'
$ echo "blahblahblah" > readme.txt
$ git add readme.txt
$ git commit -m "+readme.txt"

# rename it to 'README.txt'
$ git mv -f readme.txt README.txt
$ git commit -m "readme.txt => README.txt"

$ git status
On branch master
nothing to commit, working directory clean

$ git checkout HEAD~1
error: The following untracked working tree files would be overwritten by     checkout:
        readme.txt
Please move or remove them before you can switch branches.
Aborting

Why git doesn't allow to checkout previos commits?

You face with the same problem when delete one file and append another one with the same name, but different case. No matter how many commits you do: one (removing and appending in the same commit) or two commits (in first commit you remove file, in second you add another one).

Upvotes: 0

Views: 3470

Answers (1)

Chris
Chris

Reputation: 136967

On Windows git can't handle files with the same name but in different case properly

Git on Windows can't handle it because Windows itself can't handle it (emphasis mine):

As part of the requirements for POSIX compliance, the Windows NT File System (NTFS) provides a case-sensitive file and directory naming convention. Even though NTFS and the POSIX subsystem each handle case-sensitivity well, 16-bit Windows-based, MS-DOS-based, OS/2-based, and Win32-based applications do not.

In truth, Windows does have some level of support for NTFS case-sensitivity, but it's pretty flaky:

However, if you attempt to open one of these files in a Win32 application, such as Notepad, you would only have access to one of the files, regardless of the case of the filename you type in the Open File dialog box.

Other inconsistencies also exist. The Windows NT Command Prompt and File Manager correctly display the names of the files. However, normal commands, such as COPY, fail when you attempt to access one or more filenames that differ only in case.

Upvotes: 1

Related Questions