0
0

More than 1 year has passed since last update.

間違えてディレクトリを削除してしまったときの対処法

Posted at

ファイルを削除してしまったとき

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

これで一つ前のコミットまでワークツリーの状態を戻せる。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0