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

时间:2015-05-28 17:31:12

标签: git stage git-index git-stage

在我的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

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

1 个答案:

答案 0 :(得分:2)

您可以使用checkout命令执行此操作,就像那样:

git checkout file1
git checkout file4

希望这个帮助