小ネタです。
$ git add -A error: 's/' does not have a commit checked out fatal: adding files failed
addできない。困った。
何が起きているのか
$ ls README.md s/ $ ls -la s total 12 drwxr-xr-x 3 masawada masawada 4096 Jan 7 16:46 ./ drwxr-xr-x 4 masawada masawada 4096 Jan 7 16:46 ../ drwxr-xr-x 7 masawada masawada 4096 Jan 7 16:46 .git/
どうやら s というディレクトリが作られていて、中に .git ディレクトリが作られている状態。しかしこんなディレクトリを作った記憶はない… 一体何故…
ディレクトリが作られた原因を探る
ひとまずhistoryを眺めたところ、いつもと様子がおかしいコマンドを発見しました。
$ git git s
自分はgitconfigのaliasで git s を git status -sb に指定しています。
[alias]
s = status -sb
しかし git を重ねてしまっているのがおかしそう。実行してみましょう。
$ git git s WARNING: You called a Git command named 'git', which does not exist. Continuing in 0.1 seconds, assuming that you meant 'init'. Initialized empty Git repository in /home/masawada/sandbox/git/s/.git/
やはりこれが原因でディレクトリが作られていた!! しかし平時は git git と重ねても単にエラーが出て終了するだけです。
assuming that you meant 'init'
これはgitconfigでautocorrectを有効にしているから。git git と重ねると git init に補完されてリポジトリのディレクトリが作られてしまう、というオチでした。
[help]
autocorrect = 1
autocorrectについてはこちら