问题描述
我试图学习Git。 git rm - 缓存文件
和
git重置文件
这两个命令似乎都将文件从暂存区域移至非暂存区域。 $ c>将从索引中完全删除文件的内容。这意味着在提交时,文件将从 HEAD
提交中删除。 (如果该文件仅添加到索引中,但尚未跟踪,则这是一个no-op。)
git reset - < ; file>
将索引中的文件内容重置为与头提交相同。这意味着在提交不会更改将提交到该文件。如果 HEAD
提交中没有跟踪文件版本,则此操作无效。
I'm trying to learn Git. I'm confused between
git rm --cached file
and
git reset file
both of the commands seem to take the file from staged to un-staged area. How do the commands differ?
git rm --cached <file>
will completely remove the file's contents from the index. This means that on commit the file will be removed from the HEAD
commit. (If the file was only added to the index and not yet tracked this is a "no-op".)
git reset -- <file>
resets the contents of the file in the index to be the same as the head commit. This means that on commit no changes will be committed to the file. This operation is not valid if there is no tracked version of the file in the HEAD
commit.
这篇关于git rm - 缓存文件vs git重置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!