2

I'm on a case-insensitive file system (Windows) and changed the case of several files (a lot of files are affected, so I'm not eager to do it again).

I expected that committing the changes would be easy. But git is not aware of the changes, so I got stuck.

My feeling is that there must be a way to tell git: "Look at the names as they are currently stored on the disk. Commit them exactly like this, i.e. do git mv Foo foo if the case differs from the file in the index."

I've got TortoiseGit installed but couldn't find such an option. I tried to set core.ignorecase = true but this doesn't seem to make any difference.

Thanks, TF

TheFish
  • 183
  • 1
  • 10
  • I can't really make our your question... – MrTux Aug 31 '16 at 12:40
  • Question is: How can I transfer the changes that I made in the file systems (500+ files renamed) into the git repository / index, without typing `git mv` or doing `right-click -> Rename` 500+ times? – TheFish Aug 31 '16 at 12:56

6 Answers6

4

You need to get git to refresh your files in the git index, however, it does not pick up on case sensitive changes on a case-intensive OS.

Instead, you can force it to update the index with

git rm -r --cached . 
git add .

Do not forget to commit next.

source

Dorus
  • 7,276
  • 1
  • 30
  • 36
2

After investigating my problem again I came to the conclusion that there is no solution. I ended up writing a Batch script to rename my files using git mv.

IMHO the whole case-insensitive vs. case-sensitive problem would not be an issue if Git would handle files case-sensitive even on a case-insensitive file system. Of course you cannot have the file "foo.txt" next to "Foo.TXT" in Windows or OS X, but there is no reason, why Git petulantly ignores the difference on Windows or OS X after a rename (because both systems are very well case-aware).

TheFish
  • 183
  • 1
  • 10
0

IIRC core.ignorecase = true is automatically set to true on git repositories created/cloned on windows.

If you want to rename files, you can use the context menu "Rename" option (you might need to hold the Shift-key to see it - configurable in TortoiseGit options) in order to execute a git mv operation.

MrTux
  • 32,350
  • 30
  • 109
  • 146
0

You can rename the root folder(s) to name_, commit, then change it back and commit.

This works because when you change the root folder from name to name_, it removes all files under the name folder -- both the lowercase and uppercase versions.

However, this seems to cause problems with the file history, ie. the "Compare with last revision" and such commands can't find the last revision. (since you relocated them all to a different path for one commit)

Venryx
  • 15,624
  • 10
  • 70
  • 96
0

You can try using this utility here: https://github.com/tawman/git-unite

(I haven't been able to try it myself yet, as the author doesn't provide the final exe files, and I had an issue when trying to run the build script. But it seems to be a utility that would solve this issue more easily.)

Venryx
  • 15,624
  • 10
  • 70
  • 96
0

The solution provided by Venryx is a good one. I was able to compile the Git-Unite repository by following directions in the README.md file and after making one correction in the UniteRepository.cs file on line 223: change _gitRepository?.Dispose(); to _gitRepository.Dispose();

Once you have the executable simply apply it with: git.unite.exe [OPTIONS] [repository_folder]. This works like a champ.

RobC
  • 22,977
  • 20
  • 73
  • 80