1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ファイル名を変更(小文字->大文字)したのに、gitに追跡されない??

Posted at

はじめに

getData.phpGetData.phpにリネームしてpushしたのに、PRを確認するとファイル名が変わってない??? ローカルではGetData.phpになってるのに...
今回はこの問題の解決方法を解説していきます。

なぜgitはファイル名の更新を追跡してくれなかったのか?

Windowsのファイルシステム(NTFSやFAT)とmacOSのファイルシステム(HFS+やAPFS)は、デフォルトで大文字と小文字を区別しないようになっています。

  • Windowsは先輩であるMS-DOSとの互換性を重視して、大文字と小文字を区別しない文化が引き継がれた。
  • macOSは一般ユーザ向けの使いやすさを重視して、デフォルトで大文字と小文字を区別しない設定になっている。(変更可能)

このため、小文字から大文字に変更しただけのファイル名変更はGitが正しく認識できなかったみたいです。

また、localではGetData.phpのままだったのはmacOSが大文字小文字の情報を保持してくれるからみたいです。(ちょっと混乱する..)

解決方法

ファイル名を変更する場合

git mv /path/to/getData.php /path/to/GetData.php

ディレクトリ名を変更する場合

ファイル名の変更と違い、ディレクトリはGitが直接追跡しないため、一旦違う名前にするのが良いようです。

git mv app/ app_temp/ //ディレクトリを変更した、と認識させる
git mv app_temp/ App/ //GitがApp/を追跡できるようにする

最後に

参考になれば幸いです🍏

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?