我们已经修改了路径为
path/to/another/
和path/to/main/
下的文件。path/to/main/
下的文件已经添加到git缓存中,但我们再次更新了path/to/main/Bar.php
文件。现在我们有以下情况:$ git status
[...]
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: path/to/main/Foo.php
modified: path/to/main/Bar.php
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: path/to/main/Bar.php
modified: path/to/another/Aaa.php
modified: path/to/another/Bbb.php
请注意,路径/path/to/main/Bar.php出现了两次。
我需要一条命令,可以重新添加之前添加的文件,而无需使用特定路径。
附注:git add --update
会添加所有这些文件。但它不起作用。
另外,此命令应能重新添加“modified:”和“new file:”类型的文件。
更新1
感谢@AyonNahiyan,是的,它在bash中可行。但也许有一种不使用bash技巧(子命令)的命令。
git reset
然后再次执行git add
。 - potamegit reset
命令时,你将失去文件列表。这并不起作用。 - Kirbygit reset
会从“stage”中删除文件。假设我们有20个位于不同目录下的文件,那将是一场灾难 :) - Kirbygit reset -- path/to/main/Bar.php
。然后再次运行git add path/to/main/Bar.php
。 - potame