git rm --cached <filePath>
does not unstage a file, it actually stages the removal of the file(s) from the repo (assuming it was already committed before) but leaves the file in your working tree (leaving you with an untracked file).
(git rm --cached <filePath>
不会 取消 git rm --cached <filePath>
文件,它实际上会从repo中删除文件 (假设它之前已经提交过),但是将文件保留在工作树中(让你无法跟踪)文件)。)
git reset -- <filePath>
will unstage any staged changes for the given file(s).
(git reset -- <filePath>
将取消暂存给定文件的任何暂存更改。)
That said, if you used git rm --cached
on a new file that is staged, it would basically look like you had just unstaged it since it had never been committed before.
(也就是说,如果你在一个新的文件中使用了git rm --cached
,它基本上看起来就像你刚刚从未提交它一样,因为它之前从未提交过。)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…