如何配置Git支持大小写敏感和修改文件名中大小写字母呢?(转)

时间:2022-12-01 06:49:53

1. 在新建代码文件时,不注意把文件名应该小小写搞错了
2. 文件已经push到远程了
3. 在windows下面将文件名字改为全小写

改好后,在Git中没有任何反应,使用git status时,如果遇到下面情况,说明GIT大小写不敏感,如下:

 
1
2
3
4
5
6
[rock@ROCK-PC]$ /d/WampServer/www/hexu.org/code (dev)
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
 
nothing to commit, working directory clean

如何解决Git的大小不敏感问题呢?
1. 方案一是设置Git大小写敏感:

 
1
$ git config core.ignorecase false

2. 方案二是先删除文件,再添加进去:

 
1
$ git rm ; git add  ;  git commit -m "rename file"

由于我是与大家共用的仓库,所以我采用的方案2解决掉了。

 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
$ git rm code/library/BuildTag*.php; git status
On branch dev
Changes to be committed:
  (use "git reset HEAD ..." to unstage)
 
        deleted:    code/library/BuildTagAfc.php
        deleted:    code/library/BuildTagAfs.php
 
rock@ROCK-PC /d/WampServer/www/hexu.org/code (dev)
$ git add code/library/BuildTag*.php; git status
On branch dev
Changes to be committed:
  (use "git reset HEAD ..." to unstage)
 
        renamed:    code/library/BuildTagAfc.php -> code/library/BuildTagafc.php
        renamed:    code/library/BuildTagAfs.php -> code/library/BuildTagafs.php

http://blog.hexu.org/archives/1909.shtml