はじめに
ファイル名は極力日本語にしないほうがいいとは思いつつ…。
そういうケースに当たった場合のGitの設定についてのお話です。
結論
# コマンドは適用範囲に応じて変更いただく感じで git config --local core.quotepath false git config --global core.quotepath false
具体例
Before
$ touch テスト.md $ $ git status On branch main Untracked files: (use "git add <file>..." to include in what will be committed) "\343\203\206\343\202\271\343\203\210.md"
After
$ touch テスト.md $ $ git status On branch main Untracked files: (use "git add <file>..." to include in what will be committed) テスト.md
参照元(マニュアル)
$ git config --help
... core.quotePath Commands that output paths (e.g. ls-files, diff), will quote "unusual" characters in the pathname by enclosing the pathname in double-quotes and escaping those characters with backslashes in the same way C escapes control characters (e.g. \t for TAB, \n for LF, \\ for backslash) or bytes with values larger than 0x80 (e.g. octal \302\265 for "micro" in UTF-8). If this variable is set to false, bytes higher than 0x80 are not considered "unusual" any more. Double-quotes, backslash and control characters are always escaped regardless of the setting of this variable. A simple space character is not considered "unusual". Many commands can output pathnames completely verbatim using the -z option. The default value is true. ...
パスを出力するコマンド(例:ls-files、diff)は、パス名中の「普通でない」文字を引用符で囲みます。 パス名を二重引用符で囲み、Cが制御文字をエスケープするのと同じように、それらの文字をバックスラッシュでエスケープする。 (をエスケープするのと同じ方法で、パス名の "変わった "文字を二重引用符で囲んでバッ クスラッシュでエスケープします(例えば、"TAB "は \t、"LF "は ˶n、"バックスラッシュ "は˶n)。 を表す8進数)。この変数をfalseに設定すると、0x80より大きいバイトは "unusual "とみなされなくなる。 ダブルクォート、バックスラッシュ、制御文字は、この変数の設定に関係なく、常にエスケープされる。単純なスペース文字は "unusual "とはみなされない。多くのコマンドは、-zオプションを使ってパス名を完全にそのまま出力することができる。 デフォルト値はtrueである。
www.DeepL.com/Translator(無料版)で翻訳しました。
日本語は「普通ではない」ということか…w
終わりに
ちなみにgit add
するときなどに日本語でファイル名を指定すれば、エスケープされていたとしてもファイルに対しての操作は可能です。
でも見た目でファイル名がわからないですし…こちらの設定をオススメします。
以上でした。