4

I am working on Mac. Something has happened that changed the capitalisation of my files (and I started modifying them before noticing), but git doesn't see any difference. Looking at similar problems (I change the capitalization of a directory and Git doesn't seem to pick up on it, Changing capitalization of filenames in Git, How do I commit case-sensitive only filename changes in Git?, https://ocroquette.wordpress.com/2014/07/08/git-capitalization-of-file-names-and-name-conflicts/ ) I tried to set git config core.ignorecase false but git still doesn't see the difference in the names .

At the end I solved by removing everything and doing checkout again, I wonder if there was a cleaner solution.

Here is a simplification of my session:

#Create repository

$ mkdir test && cd test && git init && git config core.ignorecase false
Initialized empty Git repository in /Users/myName/Work/test/.git/
$ git --version
git version 1.8.5.2 (Apple Git-48)
$ git config core.ignorecase
false
$ touch UPPERCASE.txt lowercase.txt CamelCase.txt 
$ git add * && git commit -a -m "Original repository"
[master (root-commit) 3eeae11] Original repository
 3 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 CamelCase.txt
 create mode 100644 UPPERCASE.txt
 create mode 100644 lowercase.txt

#some other process has messed up my filenames 
$ for f in *.txt;do newname=$(echo $f|tr 'A-Z' 'a-z');mv $f $newname;done && ls .
camelcase.txt   lowercase.txt   uppercase.txt
$ git diff
#why there isn't any diff according to git? 

#Now commit the files with the wrong capitalization 
$ for f in *.txt;do echo "I am modifiying the file too" >> $f; done 
$ git commit -am "file modified in content and filename" 
[master 6f868b8] file modified in content and filename
 3 files changed, 3 insertions(+)

$ git diff
#again any diff according to git
$ git config --get core.ignorecase 
false

$ git reset --hard HEAD && ls 
HEAD is now at 6f868b8 file modified in content and filename
camelcase.txt   lowercase.txt   uppercase.txt

$ git checkout master && ls 
Already on 'master'
camelcase.txt   lowercase.txt   uppercase.txt

#out of desperation, but luckily it worked!
$ rm *.txt && git reset --hard HEAD && ls 
HEAD is now at 6f868b8 file modified in content and filename
CamelCase.txt   UPPERCASE.txt   lowercase.txt
Community
  • 1
  • 1
lib
  • 2,918
  • 3
  • 27
  • 53
  • `$ git mv --force original-name new-name` – hjpotter92 Mar 02 '16 at 09:11
  • In the real case it is not practical for me to check the correct capitalization of every file, but this is what I get if I try after the step "some other process has messed up my filenames" : `$ git mv --force camelcase.txt CamelCase.txt ` `fatal: not under version control, source=camelcase.txt, destination=CamelCase.txt` – lib Mar 02 '16 at 09:15

0 Answers0