Vimの操作を間違って、:w
なんてファイルを作ってしまい、さらにそれをgit add
してしまいました。
こういうファイルをgitの管理外とするためには
git rm --cached '\:w'
と入力します。
で、コロンをうまくエスケープさせようしたときの試行錯誤をシミュレートすると、こんな感じになります。
$ touch :w
$ ls
:w Rakefile config.ru log vendor
Gemfile app db public webrat.log
Gemfile.lock bin doc script
README.markdown config lib spec
$ git add .
$ git status
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
#
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# new file: :w
#
$ git rm --cached :w
fatal: pathspec 'w' did not match any files
$ git rm --cached \:w
fatal: pathspec 'w' did not match any files
$ git rm --cached ':w'
fatal: pathspec 'w' did not match any files
$ git rm --cached '\:w'
rm ':w'
$ git status
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# :w
nothing added to commit but untracked files present (use "git add" to track)
$ rm :w
$ git status
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
#
nothing to commit (working directory clean)