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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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 theHEADcommit. (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 theHEADcommit.