osx - How to weed out case-sensitivity issues in git on OS X? -


when trying

git mv dir1/file.py dir2 

i get

fatal: not under version control, source=dir1/file.py, destination=dir2/file.py 

to debug run

git ls-files | grep file.py 

luckily had alias grep="grep -i" , problem clear. file.py under version control. file.py isn't.

i'm guessing have once renamed file.py file.py shell (on os x requires going through third name). git continued treat 2 files same, because os x treats them one. git refuses move file unless case matches.

how systematically determine whether there similar case sensitivity problems lurking within git repo?

i'm using default formatting of os x extended (journaled), not case-sensitive, , i'd keep way.

update

i noticed relevant post.

this bit hacky, should work, in bash:

git ls-files | xargs -i{} sh -c 'ls "{}"* &>/dev/null || echo {}' 

the goal run command reveals actual case of file.

consider this:

$ ls a.md 

we have single file named a.md. then:

$ ls a.md a.md 

what? though actual name a.md, shell matches a.md -- wrong case.

luckily, works differently when use globs:

$ ls a.md* ls: a.md*: no such file or directory $ ls a.md* a.md 

this we're looking for: doing ls the-file*, can verify if exact name exists or not.

for work, nocaseglob option of bash must off:

shopt -u nocaseglob 

the command @ top runs each file in repository shell:

ls "{}"* &>/dev/null || echo {} 

here, {} name of file in loop iteration, , try ls {}*, discard output of command, , if command failed, print filename tried. command fails if file doesn't exist: example because case of filename different.

the output of command @ top list of files in git repository, cannot found same name. these files need fix.

limitations: command may not work in cases:

  • if have multiple files same beginning
  • if have files newline in name

lastly, can change case of file without going through 3rd intermediary name in finder.

if have no changes in working tree, simple way fix names remove them workspace , checkout:

git ls-files | xargs -i{} sh -c 'ls "{}"* &>/dev/null || echo {}' | xargs rm git checkout . 

Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -