git cleanコマンドでディレクトリを削除する方法
git cleanコマンドでディレクトリを削除するには-dオプションを指定します。
オプションの説明
-d Normally, when no <path> is specified, git clean will not recurse into untracked directories to avoid removing too much. Specify -d to have it recurse into such directories as well. If any paths are specified, -d is irrelevant; all untracked files matching the specified paths (with exceptions for nested git directories mentioned under --force) will be removed.
-dオプションを指定した場合(-nオプションはドライラン)
$ git status On branch master Changes to be committed: (use "git restore --staged ..." to unstage) modified: a.txt new file: b.txt new file: test1/c.txt Untracked files: (use "git add ..." to include in what will be committed) d.txt test2/ $ git clean -n -d Would remove d.txt Would remove test2/
-dオプションを指定しない場合
$ git status On branch master Changes to be committed: (use "git restore --staged ..." to unstage) modified: a.txt new file: b.txt new file: test1/c.txt Untracked files: (use "git add ..." to include in what will be committed) d.txt test2/ $ git clean -n Would remove d.txt