ファイルを削除してしまったとき
rm -rf app/controllers/
git status
On branch main
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
deleted: app/controllers/application_controller.rb
deleted: app/controllers/concerns/.keep
no changes added to commit (use "git add" and/or "git commit -a")
その変更をgit addしていなければ次のコマンドを実行。
git checkout -f
これで一つ前のコミットまでワークツリーの状態を戻せる。