LoginSignup
7
6

More than 5 years have passed since last update.

git rmし忘れたファイルを一括処理する

Posted at

gitでいつも忘れてしまうのがgit rmコマンド。

気づいた時にはこんなことになってることが多いのではないでしょうか。

$ git status
# On branch hogehoge
# Changes not staged for commit:
#   (use "git add/rm <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       deleted:    hello/1
#       deleted:    hello/2
#       deleted:    hello/3
#       deleted:    hello/world/1
#       deleted:    hello/world/2
#       deleted:    hello/world/3

こんな時は以下のコマンドを使ってdeletedとなっているファイルを一括でgit rmしています。

$ git status | grep deleted | awk '{print $3}' | xargs rm

もう少しいい方法があれば知りたいです!

7
6
2

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
7
6