What is the difference between git rm --cached and git reset ?

后端 未结 2 590
星月不相逢
星月不相逢 2021-02-04 04:46

According to the git rm documentation,

--cached
Use this option to unstage and remove paths only from the index.    
Working tree files, whether modified or not         


        
2条回答
  •  花落未央
    2021-02-04 04:56

    git rm --cached removes the file from the index but leaves it in the working directory. This indicates to Git that you don't want to track the file any more.

    git reset HEAD leaves the file as a tracked file in the index, but the modifications cached in the index are lost. This has the effect as if the file in cache had been over written by the file in HEAD (and the working tree file being untouched)

提交回复
热议问题