From what I understand these two commands work in different ways but I can't see the difference:
git rm --cached (archivo)
git reset HEAD (archivo)
I was testing on my PC and at first glance they seem the same.
From what I understand these two commands work in different ways but I can't see the difference:
git rm --cached (archivo)
git reset HEAD (archivo)
I was testing on my PC and at first glance they seem the same.
The differences are as follows:
git rm --cached <file>
: remove the file from the index, this means that Git will no longer track it. Although the file will still exist in your directory, as it is.git reset HEAD <file>
: returns the file to its last commit and it is still tracked by git, that is, you can doadd
,commit
, etc. completely normal.If you do
git status
, you will realize that the file you applied to isgit rm --cached <file>
no longer tracked by Git because it no longer appears.git rm --cached: Removes the files from our local repository and staging area, but keeps them on our hard drive. It basically tells Git to stop tracking the change history of these files, so they will go into an untracked state.
git reset HEAD: This is the command to get files out of the staging area. Not to delete them or anything, just so that the latest changes to these files don't get pushed to the last commit, unless we change our mind and stage them back with git add of course.