1

I'm working on a python project and want to rename a (package) folder to small letters, let's say from Myackage to mypackage. As git is case-sensitive and Windows is not, I followed the solutions taken from here and espacially here.

My procedure was as follows:

git mv Mypackage tmp
git mv tmp mypackage
git commit -m "Change capitalization of package name"

This changes the folder Myackage to mypackage with success (for both, git and Windows). But if I switch to another branch, I expect the folder to change back to Mypackage (with capital letter!), as it was before. Background is, that all the imports of the package are also case-sensitve in python and i need this renamng acompanied with adaptions of the imports.

I've tried both, core.ignorecase set to true and false, but no matter what I try, if I checkout an older branch, the folder remains in form of small letters (mypackage) and I run into issues within python.

UPDATE: I've set up a small example with only one Folder and one file and could succesfully change the capitalization of the folder. It also shows the desired behaviour, that upon branch switch the capitalization of the folder in Windows changes, yet still this won't work for my python project.

Could it be, that, e.g., submodules, play a role here?

UPDATE 2: I've checked the case sensitivity attribute for both cases via:

fsutil.exe file queryCaseSensitiveInfo .

Both folders claim, that case-sensitivity is deactivated. Still for one project folder name capitalization changes, but for the other folder not.

AnsFourtyTwo
  • 2,480
  • 2
  • 13
  • 33
  • I see the behavior you expect on my machine, I do not know how to reproduce the other one. What version of git do you use ? – LeGEC Dec 16 '19 at 12:54
  • The question is if everything is case insensitive, how should the change branch behave? If you have case insensivity the Mypackage and mypackage are the same and that is the reason why changing the branches don't change between Mypackage and mypackage. – tukan Dec 16 '19 at 13:00

2 Answers2

3

The attribute case sensitivity is available on Windows 10 but after April 2018 Update and only affect the specific folder to which you apply it. It isn’t automatically inherited by that folder’s subfolders. However, if you use WSL to create folders it's enabled by default and available in that way to Windows. [1]

Although you can use the Git Unite [2] tool to match the case of the current folders with the git index.

If you use the rename approach, try using it with git commands like in "Rename files and folders with git"[3]

git mv foldername tempname && git mv tempname folderName
nilsandrey
  • 1,030
  • 11
  • 28
2

I found a way to reproduce your behavior :

if my CaSeD folder contains some extra files (untracked files for example), git will not change the case of my folder name when I jump between commits.

Is this the case in your setup ?


If this is your issue : you could go with a post-checkout hook, which forcibly renames the folders according to what is stored in HEAD after a checkout.

One way to get the full list of paths to directories from commit HEAD is :

git ls-tree --name-only -d -r HEAD

If you match this list with a similar list extracted from your local file system (ls -r ? find . -type d ? some python function from os.* ?), you can spot what folders need to be recapitalized.

LeGEC
  • 46,477
  • 5
  • 57
  • 104
  • Seems like this is the cause, why the folder capitalzation does not change. This is even true, if a have file not tracked but being listen in `.gitignore`. – AnsFourtyTwo Dec 16 '19 at 14:02
  • I added a starting point for a post-checkout script, to list the directory names and spot the miscapitalized ones. It's not a satisfactory fix, but it is the only systematic way I can think of. – LeGEC Dec 17 '19 at 16:07