git error Will not add file alias xxx already exists in index

1,416 阅读1分钟

修改文件/文件夹名称,报错:Will not add file alias xxx already exists in index

fatal: Will not add file alias 'src/components/PreviewPlatform/MockPhone/index.tsx' ('src/components/PreviewPlatform/mockPhone/index.tsx' already exists in index)

原因:git 不区分大小写,对大小写不敏感。

解决步骤:

  1. 选择要修改的文件/夹,改为任意名称:name_temp.js;
  2. git add . 暂存这次的修改;
  3. 修改要修改的文件/夹的名字: Name.js;
  4. git add . 暂存这次修改,则改名成功!