假设我在git存储库中有一个名为foo
的文件。
假设已经用rm
(而不是git rm
)删除了它。然后git的状态会显示:
Changes not staged for commit:
deleted: foo
我如何进行这个单独的文件删除?
如果我试着:
git add foo
它说:
'foo' did not match any files.
更新(9年后,哈哈):
看起来git 2.x已经修复了这个问题:
$ git --version
git version 2.25.1
$ mkdir repo
$ cd repo
$ git init .
Initialized empty Git repository in repo/.git/
$ touch foo bar baz
$ git add foo bar baz
$ git commit -m "initial commit"
[master (root-commit) 79c736b] initial commit
3 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 bar
create mode 100644 baz
create mode 100644 foo
$ rm foo
$ git status
On branch master
Changes not staged for commit:
deleted: foo
$ git add foo
$ git status
On branch master
Changes to be committed:
deleted: foo