gitで「does not have a commit checked out」というエラー

スポンサーリンク
Uncategorized

はじめに

gitを使っていたら、「does not have a commit checked out」というエラーに遭遇したので備忘の意味を込めて記録します。

エラー対応

error: ‘ref_voice_backend/ref_voice_backend/’ does not have a commit checked out

git addしたときに以下のようなエラーが発生。

$ sudo git add ./
error: 'ref_voice_backend/ref_voice_backend/' does not have a commit checked out
fatal: adding files failed

該当フォルダに行って確認してもbranchが設定されていないです。

$ cd ref_voice_backend/ref_voice_backend/

ref_voice_backend/ref_voice_backend$ git branch

しかし、「.git」フォルダがありました。

$ ls -la ref_voice_backend/ref_voice_backend/
total 444
drwxr-xr-x   7 xxx xxx 4096 Sep 27 09:23 .
drwxr-xr-x   4 xxx xxx 4096 Sep 20 20:38 ..
drwxr-xr-x   7 xxx xxx 4096 Sep 20 20:37 .git
-rw-r--r--   1 xxx xxx  686 Sep 20 20:37 .gitignore
-rw-r--r--   1 xxx xxx   51 Sep 20 20:37 .prettierrc
-rw-r--r--   1 xxx xxx 5028 Sep 20 20:37 README.md
・・・
-rw-r--r--   1 xxx xxx   97 Sep 20 20:37 tsconfig.build.json
-rw-r--r--   1 xxx xxx  674 Sep 20 20:37 tsconfig.json

これを削除したらaddできました。

$ rm -rf ref_voice_backend/ref_voice_backend/.git
$ sudo git add ref_voice_backend/ref_voice_backend
$ sudo git commit -m "fix: サブモジュール誤認識を解除"

最後に

以上、簡単ですが、プチエラー対応でした。

タイトルとURLをコピーしました