如何删除未跟踪的更改但保留索引更改

how to remove untrack changes but keeping indexed changes

在我的 git 状态下我看到了这个

Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

modified: file1
modified: file2
modified: file4

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: file1
modified: file4

如何将文件重置为当前暂存更改并仅丢弃非暂存更改。

您可以使用 checkout 命令来完成,就像这样:

git checkout file1
git checkout file4

希望对您有所帮助