Git大小写不敏感导致提交文件冲突问题解决
source link: https://chegva.com/6025.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Git大小写不敏感导致提交文件冲突问题解决
问题现象:gitlab仓库上有个大写的文件名,本地改了小写后,提交后远程库上文件名没有变化,导致冲突。
解决方法1:使用 git mv
git mv
Move or rename files and update the Git index.
More information: <https://git-scm.com/docs/git-mv>.
- Move a file inside the repo and add the movement to the next commit:
git mv path/to/file new/path/to/file
- Rename a file or directory and add the renaming to the next commit:
git mv path/to/file_or_directory path/to/destination
- Overwrite the file or directory in the target path if it exists:
git mv --force path/to/file_or_directory path/to/destination
解决方法2:设置本地Git大小写敏感
$ git config --get core.ignorecase
true
$ git config core.ignorecase false
$ git config --get core.ignorecase
false
关于 是否区分大小写 的补充说明
针对文件/文件夹,Windows 系统和 Mac 系统是不区分大小写的;Linux 系统是区分大小写的;Git 默认是不区分大小写的,也可以通过改配置项,改为区分大小写。
不分区大小写,也有它的好处,比如:文件夹/文件的路径,很多时候就代表了网站地址、页面url的路径。而网站地址也是不区分大小写的,这是很关键的原因之一。
关于 Git是否区分大小写 的补充
Git 默认是不区分大小写的,可以通过命令git config --get core.ignorecase查到,默认值是 true。
我们也可以修改 Git 的这一配置项,改为区分大小写,配置命令为git config core.ignorecase false。
不管是 Windows 还是其他系统下,还是不要轻易修改 git 默认的 core.ignorecase
配置,使用规范的 git mv
做法就好。
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK