我在我的本地repo中修改了一些文件,然后我做了git add -A,我认为这给暂存区添加了太多的文件。如何从暂存区删除所有文件?

之后,手动执行gitaddfilename。


当前回答

使用以下命令从暂存区删除特定文件:

git restore --staged <individual_file>

或者使用以下命令删除当前暂存的所有文件:

git restore --staged .

在你的git bash终端中,在将文件添加到暂存区域后,你可以运行git状态,命令会显示在当前暂存文件的上方:

其他回答

非常简单的答案

下面的git命令将从暂存区删除所有文件

git restore --staged .

或者你可以

git restore -S .

注意:从项目根目录运行这些命令,不要忘记。(点)在最后!

使用以下命令从暂存区删除特定文件:

git restore --staged <individual_file>

或者使用以下命令删除当前暂存的所有文件:

git restore --staged .

在你的git bash终端中,在将文件添加到暂存区域后,你可以运行git状态,命令会显示在当前暂存文件的上方:

Use

git reset

取消所有已登台的文件。

现在在v2.24.0建议

git restore --staged .

取消文件。

你可以用

git reset HEAD

然后添加您想要的特定文件

git add [directory/]filename