gitコマンドを使わず削除してしまったファイルの扱い

gitで管理されているファイルを普通にrmコマンドで削除してからcommitしようとすると次のようなメッセージが出てコミットの対象外になってしまいます。

$ git status
# On branch master
# Changes to be committed:
# (use “git reset HEAD <file>…” to unstage)
#
# modified: HogehogeApp/static/css/bootstrap.css
# new file: HogehogeApp/static/css/bootstrap.css.map
# modified: HogehogeApp/static/css/bootstrap.min.css
略
#
# Changed but not updated:
# (use “git add/rm <file>…” to update what will be mmitted)
# (use “git checkout — <file>…” to discard changes in working ectory)
#
# deleted: HogehogeApp/static/css/base.css
# deleted: HogehogeApp/static/css/changelists.css
# deleted: HogehogeApp/static/css/dashboard.css
# deleted: HogehogeApp/static/css/forms.css
略

解決策は簡単で数が少ないときは、deletedで示されたファイルを

$ git rm HogehogeApp/static/css/base.css

としてからcommitすればOKなのですが、数が多いと都度rmするのは大変なので、

$ git status | grep deleted | awk ‘{print $3}’ | xargs git rm
$ git commit

と一括で削除してからcommitしましょう。