【发布时间】:2012-09-04 14:54:06
【问题描述】:
假设我的 git 存储库中有一个名为 foo 的文件。
假设它已被rm(不是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
【问题讨论】:
-
这是旧 Git 版本的问题吗?现在它似乎不是一个,它的工作方式类似于修改后的文件。
-
@cst1992:是的,现在看起来已经修复了。
git add foo现在可以使用了。请参阅更新。
标签: git git-add git-rm git-stage