最佳答案
有时git建议git rm --cached
卸载文件,有时git reset HEAD file
。我应该什么时候使用哪个?
D:\code\gt2>git initInitialized empty Git repository in D:/code/gt2/.git/D:\code\gt2>touch a
D:\code\gt2>git status# On branch master## Initial commit## Untracked files:# (use "git add <file>..." to include in what will be committed)## anothing added to commit but untracked files present (use "git add" to track)
D:\code\gt2>git add a
D:\code\gt2>git status# On branch master## Initial commit## Changes to be committed:# (use "git rm --cached <file>..." to unstage)## new file: a#D:\code\gt2>git commit -m a[master (root-commit) c271e05] a0 files changed, 0 insertions(+), 0 deletions(-)create mode 100644 a
D:\code\gt2>touch b
D:\code\gt2>git status# On branch master# Untracked files:# (use "git add <file>..." to include in what will be committed)## bnothing added to commit but untracked files present (use "git add" to track)
D:\code\gt2>git add b
D:\code\gt2>git status# On branch master# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## new file: b#