假设我的 git 存储库中有一个名为foo
.
假设它已用rm
(not git rm
) 删除。然后 git status 将显示:
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